Hi all,
is there any way to run the maven-pmd-plugin on both the main and test
code, but with different rulesets?

It does not seem to be possible to run 2 executions with different
ruleset configurations...

What I have:
...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>3.12.0</version>
        <configuration>
          <rulesets>
            <ruleset>pmd-rules.xml</ruleset>
          </rulesets>
          <printFailingErrors>true</printFailingErrors>
          <includeTests>true</includeTests>
        </configuration>

        <executions>
          <execution>
            <id>pmd-check</id>
            <phase>compile</phase>
            <goals>
              <goal>check</goal>
              <goal>cpd-check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

I would like to have is something like this:
...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>3.12.0</version>
        <configuration>
          <rulesets>
            <ruleset>pmd-rules.xml</ruleset>
          </rulesets>
          <printFailingErrors>true</printFailingErrors>
        </configuration>

        <executions>
          <execution>
            <id>pmd-main-check</id>
            <phase>compile</phase>
            <goals>
              <goal>check</goal>
              <goal>cpd-check</goal>
            </goals>
            <configuration>
              <rulesets>
                <ruleset>pmd-main-rules.xml</ruleset>  <!-- "normal" rules
-->
              </rulesets>
            </configuration>
          </execution>

          <execution>
            <id>pmd-test-check</id>
            <phase>compile</phase>
            <goals>
              <goal>check</goal>
              <goal>cpd-check</goal>
            </goals>
            <configuration>
              <rulesets>
                <ruleset>pmd-test-rules.xml</ruleset>  <!-- less strict
rules for the tests -->
              </rulesets>
              <includeTests>true</includeTests>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

But it does not seem to be possible to have ruleset-configuration
inside an execution tag. Is it possible to solve this in any way?

/Ted

Reply via email to