checkstyle插件的Maven多项目依赖管理
我正在尝试将 maven-checkstyle 插件用于多模块项目,这是我的 projec 结构
|pom-root
| -- my-checkstyles
| |-- pom.xml
| |-- checkstyles
| |-- checkstyles.xml
| -- my-war
| |-- pom.xml
| -- my-ejb
| |-- pom.xml
| -- my-ear
| |-- pom.xml
| -- pom.xml
,这是我的 pom-root 项目的 pom.xml:
<project
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns=
"http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>pom-root</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>my-checkstyles</module>
<module>my-ear</module>
<module>my-ejb</module>
<module>my-war</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins </groupId>
<artifactId> maven-site-plugin </artifactId>
<version>3.0-beta-3</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>5.4</version>
</dependency>
<dependency>
<groupId>fr.info.saone</groupId>
<artifactId>info-saone-checkstyle</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<configuration>
<outputEncoding>UTF-8</outputEncoding>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.7</version>
<configuration>
<cacheFile>target/cachefile</cacheFile>
<configLocation>checkstyles/checkstyle_vnf.xml</configLocation>
<linkXRef>true</linkXRef>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
</project>
当我执行 mvn site
时,它失败了除非我在存储库中安装了 checkstyle 项目,这非常烦人,因为如果对文件进行轻微更改,我需要在存储库中再次安装它。
我知道 Maven 应该以这种方式工作,但是有没有办法配置 root pom 以在编译时解决对 checkstyle 项目的依赖关系,而不是从存储库中获取它?
我尝试使用 Maven 选项“--also-make”和“-pl”,但我无法让它工作。
我也知道我可以告诉 checkfile 使用 file:///
协议查找 checkstyle 文件(这就是我现在正在做的事情),但我宁愿找到一种替代方法。
提前致谢
I'm trying to use the maven-checkstyle plugin for a multi-module project here is my projec structure
|pom-root
| -- my-checkstyles
| |-- pom.xml
| |-- checkstyles
| |-- checkstyles.xml
| -- my-war
| |-- pom.xml
| -- my-ejb
| |-- pom.xml
| -- my-ear
| |-- pom.xml
| -- pom.xml
and here is the pom.xml for my pom-root project :
<project
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns=
"http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>pom-root</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>my-checkstyles</module>
<module>my-ear</module>
<module>my-ejb</module>
<module>my-war</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins </groupId>
<artifactId> maven-site-plugin </artifactId>
<version>3.0-beta-3</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>5.4</version>
</dependency>
<dependency>
<groupId>fr.info.saone</groupId>
<artifactId>info-saone-checkstyle</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<configuration>
<outputEncoding>UTF-8</outputEncoding>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.7</version>
<configuration>
<cacheFile>target/cachefile</cacheFile>
<configLocation>checkstyles/checkstyle_vnf.xml</configLocation>
<linkXRef>true</linkXRef>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I execute mvn site
it fails unless I have the checkstyle project installed in the repository, which is pretty annoying because if a make a slight change in the file I need to install it again in the repo.
I know Maven is supposed to work this way, but is there a way to configure the root pom to resolve the dependency to the checkstyle project at compile time and not get it from the repo?
I tried using maven options "--also-make" and "-pl" but I couldn't get it working.
Also I know I can tell checkfile to look for the checkstyle file using the file:///
protocol (thats how I'm doing it now) but I would rather find an alternative way.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论