1

伙计们,我想在构建项目时生成 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>

提前致谢。

4

2 回答 2

3

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

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

但是您应该将它与早于的阶段相关联install- 比如verify- 以便检查在install阶段之前进行。

于 2010-06-08T15:03:14.017 回答
2

嗯,对不起,这只是我在编写配置时犯的一个小错误。<executions> [...] </executions>应该没有<configuration>[...]</configuration>标签。由于插件足够智能,可以分阶段执行verify,我们不需要将它与任何阶段相关联。我们只需要将它包含在<build>您的 pom.xml 部分中。

于 2010-06-09T10:07:52.033 回答