创建pom.xml文件

Mad*_*ina 4 ant maven-2 sonarqube

anayone可以给我一些关于如何为多模块项目创建pom.xml文件的sugestions,这是用ant构建的吗?我需要创建这个pom.xml文件,以便使用Sonar分析项目.

Pas*_*ent 7

我建议按照Sonar文档中的说明进行操作.请参阅分析Java项目:

具有多个源目录的项目

如果您的非maven项目包含多个sources目录,则可以通过在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>
Run Code Online (Sandbox Code Playgroud)