anayone 可以给我一些关于如何为多模块项目创建 pom.xml 文件的建议,这是用 ant 构建的吗?我需要创建这个 pom.xml 文件以便使用 Sonar 分析项目。
问问题
10976 次
4 回答
7
我建议按照 Sonar 文档中的说明进行操作。请参阅分析 Java 项目:
具有多个源目录的项目
如果您的非 Maven 项目包含多个源目录,您可以通过在 pom.xml 文件中添加有关 Build Helper Maven 插件的新部分来指定要分析的源目录:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>[YOUR.ORGANIZATION]</groupId> <artifactId>[YOUR.PROJECT]</artifactId> <name>[YOUR PROJECT NAME]</name> <version>[YOUR PROJECT VERSION]</version> <build> <sourceDirectory>[YOUR SOURCE DIRECTORY]</sourceDirectory> <outputDirectory>[YOUR CLASSES/BIN DIRECTORY</outputDirectory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> <excludes> <exclude>**/*.*</exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.1</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>[YOUR SOURCE DIRECTORY 2]</source> <source>[YOUR SOURCE DIRECTORY 3]</source> </sources> </configuration> </execution> </executions> </plugin> </plugins> </build> <properties> <sonar.dynamicAnalysis>false</sonar.dynamicAnalysis> <sonar.phase>generate-sources</sonar.phase> </properties> </project>
替换参数:
...
并按照安装指南中的说明执行 maven2 插件:
mvn sonar:sonar
于 2010-07-05T15:44:29.970 回答
1
现在有一个Sonar Ant Task可以使用,或者还有Sonar Runner
于 2013-02-06T15:58:51.883 回答
0
我想你可以尝试使用builder-helper-maven-plugin,目前最新版本是1.5。如记录的http://docs.codehaus.org/display/SONAR/Analyzing+Java+Projects。但是,只需将插件版本更改为 1.5 并使用 mvn sonar3:sonar。最重要的是,不要忘记<sonar.phase>generate-sources</sonar.phase>,没有这个,它就行不通。
至于输出目录,如果使用eclipse,可以为每个模块指定输出目录,使它们指向同一个文件夹。将此文件夹用作 pom.xml 的输出目录。如果使用 Eclipse,请记住禁用擦洗。
于 2010-12-30T07:25:59.743 回答