ant - 创建 pom.xml 文件

标签 ant maven-2 sonarqube

谁能给我一些关于如何为多模块项目创建 pom.xml 文件的建议,即用 ant 构建的?我需要创建这个 pom.xml 文件以便使用 Sonar 分析项目。

最佳答案

我建议按照 Sonar 文档中的说明进行操作。见 Analyzing Java Projects :

Project with multiple sources directories

If your non-maven project contains more than one sources directory, you can specify which sources directories to analyse by adding a new section about the Build Helper Maven Plugin into your pom.xml file :

<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>
  • Replace the parameters :

    ...

  • And execute the maven2 plugin as explained in the installation guide :

    mvn sonar:sonar
    

关于ant - 创建 pom.xml 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3178332/

相关文章:

maven-2 - 如何在 maven 的单个 jar 中添加所有依赖项,然后应用程序集插件?

java - Maven 程序集插件因 NullPointerException 失败?

c# - MSBuild.SonarQube.Runner.exe 结束,后处理失败退出代码 1

Sonar API : projects with key that includes string

java - 构建 openfire 源的问题

android - android 中的无效文件 : google-play-services_lib/build. xml

java - 远程调试不起作用,显示错误 "Line number information is missing"

ant - 收到错误消息 : "unknown resolver XYZ"

java - 如何使用带有 eclipse 的 maven2 添加 apache 公共(public)日志记录?

java - Java中的命令注入(inject)漏洞