PMD maven插件的多次执行

multiple executions of PMD maven plugin

我尝试同时使用不同的配置多次执行 PMD maven 插件。执行确实有效,但它们始终使用第一个配置。我的想法是用 "mvn verify".

一起检查 java、jsp 和 java 脚本

找不到任何类似的文档或问题。

我的配置如下:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>3.9.0</version>
        <configuration>
            <failOnViolation>false</failOnViolation>
            <printFailingErrors>true</printFailingErrors>
        </configuration>
        <executions>
            <!-- test java -->
            <execution>
                <id>check-java</id>
                <phase>test</phase>
                <goals>
                    <goal>check</goal>
                </goals>
                <configuration>
                    <language>java</language>
                    <sourceEncoding>cp1252</sourceEncoding>
                    <rulesets>
                        <ruleset>/category/java/bestpractices.xml</ruleset>
                        <ruleset>/category/java/codestyle.xml</ruleset>
                        <ruleset>/category/java/design.xml</ruleset>
                        <ruleset>/category/java/errorprone.xml</ruleset>
                        <ruleset>/category/java/multithreading.xml</ruleset>
                        <ruleset>/category/java/performance.xml</ruleset>
                    </rulesets>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                </configuration>
            </execution>
            <!-- test jsp -->
            <!-- currently only the first configuration is working -->
            <execution>
                <id>check-jsp</id>
                <phase>test</phase>
                <goals>
                    <goal>check</goal>
                </goals>
                <configuration>
                    <language>jsp</language>
                    <rulesets>
                        <ruleset>/category/jsp/bestpractices.xml</ruleset>
                        <ruleset>/category/jsp/codestyle.xml</ruleset>
                        <ruleset>/category/jsp/design.xml</ruleset>
                        <ruleset>/category/jsp/errorprone.xml</ruleset>
                        <ruleset>/category/jsp/security.xml</ruleset>
                    </rulesets>
                    <includes>
                        <include>**/*.jsp</include>
                    </includes>
                    <compileSourceRoots>
                        <compileSourceRoot>${basedir}/WebContent</compileSourceRoot>
                    </compileSourceRoots>
                </configuration>
            </execution>
            <!-- test javascript -->
            <!-- currently only the first configuration is working -->
            <execution>
                <id>check-javascript</id>
                <phase>test</phase>
                <goals>
                    <goal>check</goal>
                </goals>
                <configuration>
                    <language>javascript</language>
                    <rulesets>
                        <ruleset>/category/ecmascript/bestpractices.xml</ruleset>
                        <ruleset>/category/ecmascript/codestyle.xml</ruleset>
                        <ruleset>/category/ecmascript/errorprone.xml</ruleset>
                    </rulesets>
                    <includes>
                        <include>**/*.js</include>
                    </includes>
                    <compileSourceRoots>
                        <compileSourceRoot>${basedir}/WebContent/javascript</compileSourceRoot>
                    </compileSourceRoots>
                </configuration>
            </execution>
        </executions>
    </plugin>

简单的解决方案:目标需要是pmd,只有这个目标有使用的配置值。