title: How to suppress PMD warnings during a Maven install
body: <p>I have a Java project that is built using <strong>Maven</strong>, thus my build process is defined in the <em>pom.xml</em> file of the project. My development team uses a variety of plugins to check the quality of our source code; one such plugin uses <strong><a href="http://pmd.sourceforge.net/" rel="nofollow noreferrer">PMD</a></strong> to check the code.The plugin makes sure that PMD is run every time we execute <code>mvn install</code> on the project and it will fail the build if there is a violation. Here is the plugin in our pom.xml:</p>
  
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-pmd-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.7.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;targetJdk&gt;1.6&lt;/targetJdk&gt;
                  &lt;linkXref&gt;false&lt;/linkXref&gt;
                  &lt;failOnViolation&gt;true&lt;/failOnViolation&gt;
                  &lt;failurePriority&gt;1&lt;/failurePriority&gt;
                  &lt;rulesets&gt;
                      &lt;ruleset&gt;config/pmd-rulesets.xml&lt;/ruleset&gt;
                  &lt;/rulesets&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;check&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>My problem is that there are some times -- especially when I am in the middle of developing a task and I want to check out if my code builds, but before I am ready to submit my source code to the SCM for automatic build and release to others -- when I will want to suppress PMD violations from failing my build. I know that one such solution is to go into the code and add annotations to suppress warnings (<a href="http://pmd.sourceforge.net/suppressing.html" rel="nofollow noreferrer">http://pmd.sourceforge.net/suppressing.html</a>), but I believe that editing source code in this way just to suppress these violations is annoying and error-prone. Another thing I could do is edit my pom and comment out the PMD plugin. However, once again, I find changing a file that is essential to my overall application is annoying and error-prone.</p>
  
  <p>The solution that my team desires for is one that allows us to simply pass in some sort of flag or argument into our <code>mvn</code> command to quickly tell the build process to skip the PMD plugin. For example, whenever we are running an install at a point in the development phase and we know that the integration tests will probably fail (like, a web service may not be active), we pass the <code>-Dskip.integration.tests=true</code> flag during <code>mvn install</code>. This is a much cleaner solution than having to edit our test files or change pom.xml. I am looking for a similar variable to allows us to quickly skip PMD violations. Thanks!</p>
  
  <p><strong>PS</strong>: I did my homework. The following two Stackoverflow questions did not contain my desired solution:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/9147938/pmd-with-maven-how-to-disable-one-rule-within-a-ruleset">PMD with Maven - How to disable one rule within a ruleset?</a></li>
  <li><a href="https://stackoverflow.com/questions/9769641/pmd-how-to-exclude-files-from-violation-check">PMD - How to exclude files from violation check</a></li></ul>