【问题标题】:why maven pmd plugin generate pmd.html为什么maven pmd插件生成pmd.html
【发布时间】:2017-03-09 10:54:13
【问题描述】:

我已经配置了我的 pom 文件,以便使用我的 pom 文件中的插件生成 pmd 报告。

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>3.0.1</version>
    <executions>
        <execution>
            <id>pmd</id>
            <phase>compile</phase>
            <goals>
                <goal>check</goal>
            </goals>
            <configuration>
                <format>xml</format>
            </configuration>
        </execution>
    </executions>
</plugin>

在这里我可以使用以下方法在我的项目目标文件夹下创建报告pmd.xml:

mvn clean compile" command

但它也在该目标文件夹下创建“站点”文件夹,并且在站点文件夹内也创建了pmd.html 文件。

why.How 进行配置,以便不会创建站点文件夹。

【问题讨论】:

    标签: maven pmd


    【解决方案1】:

    你应该看看如何使用这个插件删除报告:https://maven.apache.org/plugins/maven-pmd-plugin/examples/removeReport.html

    创建目标/站点是因为如果您检查 pmd:check goal documentation,它会说:

    在执行之前调用此插件的目标 pmd 的执行。

    然后检查 pmd:pmd goal documentation,你会看到输出目录:

    最终 HTML 报告的输出目录。请注意,仅当目标直接从命令行运行或在默认生命周期期间运行时,才会评估此参数。如果目标作为站点生成的一部分间接运行,则使用在 Maven 站点插件中配置的输出目录。 用户属性是:project.reporting.outputDirectory。

    而${project.reporting.outputDirectory} 是默认的目标/站点

    编辑:据我所知,您不能不生成 HTML 项目,但是您可以使用配置部分中的 &lt;outputDirectory&gt; 更改创建 html 报告的目录,例如实例:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-pmd-plugin</artifactId>
      <version>3.0.1</version>
       <executions>
        <execution>
            <id>pmd</id>
            <phase>compile</phase>
            <goals>
                <goal>check</goal>
            </goals>
            <configuration>
            <outputDirectory>${project.build.directory}/myHtmlPmdDirectory</outputDirectory>
                <format>xml</format>
            </configuration>
        </execution>
       </executions>
     <plugin>
    

    【讨论】:

    • 我不想生成站点文件夹。我只需要 pmd xml 文件。
    • 查看我关于修改 pom 以避免在站点文件夹中包含 HTML 报告的编辑
    • 感谢您的回复,我使用了您的插件配置但它仍然在 myHtmlPmdDirectory 和 myHtmlPmdDirectory 文件夹外的 pmd.xml 下创建 pmd.html 文件。所以我像这样编辑了 ${project.build.directory}/xml 现在 pmd.html 和 pmd.xml 都在目标文件夹下创建project.Actually 我只想要 pmd.xml 而不是 pmd.html。
    • 然后使用 /dev/null 作为输出目录或其 Windows 等效目录
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-24
    • 1970-01-01
    相关资源
    最近更新 更多