0
votes

I am using PMD maven plugin for my project and I am seeing very strange behavior in it. The following pom.xml configuration fails the build with violations in basic.xml -

<configuration>
    <rulesets>
        <ruleset>${project.basedir}\ruleset\basic.xml</ruleset>
        <!-- ruleset>${project.basedir}\ruleset\braces.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\design.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\controversial.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\coupling.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\clone.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\comments.xml</ruleset-->
    </rulesets>
</configuration>

But the below one passes the build smoothly -

<configuration>
    <rulesets>
        <ruleset>${project.basedir}\ruleset\basic.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\braces.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\design.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\controversial.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\coupling.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\clone.xml</ruleset>
        <ruleset>${project.basedir}\ruleset\comments.xml</ruleset>
    </rulesets>
</configuration>

The build should have failed in the second scenario also. As per what I have noticed, if the last rule (in above example comments.xml) does not have any code violation then the build will not break even if any of the rulesets above it (basic.xml, braces.xml, etc.) have code violations. I am unable to understand the reason behind this behavior. Can someone help me out with this?

1
Can you post the failures or better yet a sample project with the failures in a gist.Usman Ismail
Sorry for the late comment @UsmanIsmail . But what I meant in the question is that failures were fine. My project was having code violation related as per basic.xml so it was expected to show failures. But even if I do not remove those code violations and uncomment other rules (as shown above) then the build passes. More investigation showed that if the last ruleset which I mention (comments.xml in above example) in the pom.xml file does not throw any rule violation then the build passes successfully even if the project has violation as per some other rule mentioned before it.Siddharth

1 Answers

1
votes

I found the issue. There was an issue with Maven Plugin version 3.3 . Now I am using version 3.1 and the exact same code is working as expected.