我需要设置Maven插件.我已经下载了JAR.任何人都可以告诉我,为了与Maven集成或设置插件,我下一步该做什么?我应该将JAR复制到父目录中还是需要编辑任何文件?
插件是:
Ric*_*ler 13
如果Maven可以访问中央存储库,它将下载大多数插件(有些不是托管在中央,用于访问您需要在pom或设置中定义其他存储库的插件).如果在POM中配置了依赖项,Maven将在您运行相关目标时自动尝试下载它们.对于您列出的依赖项,这是mvn站点.
您列出的大多数这些罐子都是报告,因此应该在POM 的报告部分中声明(例如,我也会声明版本以确保您获得了预期的插件):
<reporting>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<linkXref>true</linkXref>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<outputDirectory>target/site/cobertura</outputDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<configuration>
<outputDirectory>${basedir}/target/surefire-reports</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<xmlOutput>true</xmlOutput>
<effort>Max</effort>
</configuration>
</plugin>
</plugins>
</reporting>
Run Code Online (Sandbox Code Playgroud)
关于Maven的插件执行模型的一些背景:当你运行mvn网站时,这是"从最新版本的网站插件运行网站目标"的简写,即它相当于mvn site:site,这又是简写为mvn org.apache.maven.plugins:maven-site-plugin:最新:网站
Maven将尝试联系中央存储库,从maven-metadata.xml确定最新版本,然后在执行之前下载它(以及任何缺少的依赖项).
如果您位于代理服务器后面,您可能会在构建日志中看到如下错误消息:
[INFO] The plugin 'org.apache.maven.plugins:maven-site-plugin' does not exist or no valid version could be found
Run Code Online (Sandbox Code Playgroud)
要解决此问题,您可以在Maven settings.xml中声明代理设置(在[MVN_HOME] /conf/settings.xml中).他们被defualt评论出来,但看起来像这样:
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net,some.host.com</nonProxyHosts>
</proxy>
Run Code Online (Sandbox Code Playgroud)
将用户名,密码,主机和端口值替换为与您的环境相关的值,Maven将能够下载所需的依赖项.
有关使用Maven的更多详细信息,请查看Sonatype 的Maven:The Definitive Guide,它是在线免费的.
您无需手动下载插件。我不是 100% 确定,但是如果你想使用 checkstyle 插件,你需要使用 checkstyle 参数形式命令行启动 Maven
就像是:
mvn checkstyle:checkstyle
Run Code Online (Sandbox Code Playgroud)
或者
mvn checkstyle:check
Run Code Online (Sandbox Code Playgroud)
edit1:但是您也可以将 jar 放入具有特定文件夹结构的本地 m2 存储库中以访问它们。
edit2:您可以将所有插件放入您自己的存储库中,然后您需要告诉maven(使用pom)您要使用哪些存储库。每个插件都必须在 pom.xml 中进行描述。