我们可以在构建目标中包含 Maven pmd 插件执行吗?

发布于 2024-09-04 13:13:37 字数 1775 浏览 6 评论 0原文

伙计们,我想在构建项目时生成 pmd 报告,因此我添加了插件来构建我的 pom.xml 部分,但它仍然不会执行,直到我明确调用 mvn clean install pmd:pmd 。我想用 mvn clean install 本身来执行它。是否可以 ?我的 pom 条目如下:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-pmd-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <skip>false</skip>
                <targetJdk>${compile.source}</targetJdk>
                <rulesets>
                    <ruleset>./current.pmd.rules.xml</ruleset>
                </rulesets>
                <excludes>
                    <exclude>com/cm/**/*.java</exclude>
                    <exclude>com/sm/**/*.java</exclude>
                </excludes>
                <linkXref>true</linkXref>
                <failOnViolation>true</failOnViolation>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                            <goal>cpd-check</goal>
                        </goals>
                    </execution>
                </executions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jxr-plugin</artifactId>
        </plugin>
        <plugin>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.0.1</version>
        </plugin>
    </plugins>

</build>

提前致谢。

Guys, I wanted generate the pmd report while building the project so I have added plugin to build section of my pom.xml but still it don't execute until I explicitly call mvn clean install pmd:pmd. I want to execute it with mvn clean install itself. is it possible ? my pom entries are as under:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-pmd-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <skip>false</skip>
                <targetJdk>${compile.source}</targetJdk>
                <rulesets>
                    <ruleset>./current.pmd.rules.xml</ruleset>
                </rulesets>
                <excludes>
                    <exclude>com/cm/**/*.java</exclude>
                    <exclude>com/sm/**/*.java</exclude>
                </excludes>
                <linkXref>true</linkXref>
                <failOnViolation>true</failOnViolation>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                            <goal>cpd-check</goal>
                        </goals>
                    </execution>
                </executions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jxr-plugin</artifactId>
        </plugin>
        <plugin>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.0.1</version>
        </plugin>
    </plugins>

</build>

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滥情空心 2024-09-11 13:13:37

您可以通过修改 pom 以包含以下代码片段,将 pmd 目标与 install 阶段相关联:

<executions>
 <execution>
  <phase>install</phase>
  <goals>
   <goal>check</goal>
   <goal>cpd-check</goal>
  </goals>
 </execution>
</executions>

但您应该将其与早于 install 的阶段相关联 - 例如 verify - 以便检查发生在安装阶段之前。

You can associate the pmd goals with install phase by modifying your pom to contain the following snippet:

<executions>
 <execution>
  <phase>install</phase>
  <goals>
   <goal>check</goal>
   <goal>cpd-check</goal>
  </goals>
 </execution>
</executions>

But you should associate it with a phase earlier than install - like verify - so that the checking happens before the install phase.

天气好吗我好吗 2024-09-11 13:13:37

嗯,抱歉,大家,这只是我在编写配置时犯的一个小错误。 ; [...] 应该在 [...] 标记之外。由于该插件足够智能,可以在验证阶段执行它,因此我们不需要将其关联到任何阶段。我们只需将其包含在 pom.xml 的 部分中。

hm sorry guys, its just a small mistake I have made while writing the configuration. The <executions> [...] </executions> should be out of <configuration>[...]</configuration> tag. Since the plugin is intelligent enough to execute it in verify phase, we need not to associate it to any phase. We just need to include it in <build>section of your pom.xml.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文