Author: mperham Date: Sun Jul 2 15:27:54 2006 New Revision: 418659 URL: http://svn.apache.org/viewvc?rev=418659&view=rev Log: PR: MPMD-31 Add skip parameter support
Added: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/skip-plugin-config.xml (with props) Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java maven/plugins/trunk/maven-pmd-plugin/src/site/apt/faq.apt maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java?rev=418659&r1=418658&r2=418659&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java Sun Jul 2 15:27:54 2006 @@ -50,6 +50,14 @@ private int minimumTokens; /** + * Skip the PMD report generation. Most useful on the command line + * via "-Dmaven.cpd.skip=true". + * + * @parameter expression="${maven.cpd.skip}" default-value="false" + */ + private boolean skip; + + /** * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale) */ public String getName( Locale locale ) @@ -71,7 +79,7 @@ public void executeReport( Locale locale ) throws MavenReportException { - if ( canGenerateReport() ) + if ( !skip && canGenerateReport() ) { CPD cpd = new CPD( minimumTokens, new JavaLanguage() ); String src = getProject().getBuild().getSourceDirectory(); Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java?rev=418659&r1=418658&r2=418659&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java Sun Jul 2 15:27:54 2006 @@ -81,6 +81,14 @@ private int minimumPriority = 5; /** + * Skip the PMD report generation. Most useful on the command line + * via "-Dmaven.pmd.skip=true". + * + * @parameter expression="${maven.pmd.skip}" default-value="false" + */ + private boolean skip; + + /** * The PMD rulesets to use. See the <a href="http://pmd.sourceforge.net/rules/index.html">Stock Rulesets</a> for a * list of some included. Defaults to the basic, imports and unusedcode rulesets. * @@ -124,7 +132,7 @@ public void executeReport( Locale locale ) throws MavenReportException { - if ( canGenerateReport() ) + if ( !skip && canGenerateReport() ) { Sink sink = getSink(); Modified: maven/plugins/trunk/maven-pmd-plugin/src/site/apt/faq.apt URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/site/apt/faq.apt?rev=418659&r1=418658&r2=418659&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/site/apt/faq.apt (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/site/apt/faq.apt Sun Jul 2 15:27:54 2006 @@ -11,3 +11,31 @@ FAQs Below are frequently asked questions for the PMD plugin: + + * The PMD report takes a long time to generate. Is there any way to skip the PMD or CPD reports temporarily? + + Yes, each report supports a skip parameter which you can pass on the command line, "-Dmaven.pmd.skip=true" and + "-Dmaven.cpd.skip=true" respectively. + + * I want to generate one of the reports but not the other. How can I permanently skip PMD or CPD? + + Use the \<reportSets\> feature within your POM. Below is the default configuration for the plugin. To disable + one of the reports, just add the \<reportSets\> below to your POM and remove the report you don't want to generate. + ++--------------------+ +<reporting> + <plugins> + <plugin> + <artifactId>maven-pmd-plugin</artifactId> + <reportSets> + <reportSet> + <reports> + <report>pmd</report> + <report>cpd</report> + </reports> + </reportSet> + </reportSets> + </plugin> + </plugins +</reporting> ++--------------------+ Modified: maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java?rev=418659&r1=418658&r2=418659&view=diff ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java (original) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/PmdReportTest.java Sun Jul 2 15:27:54 2006 @@ -109,6 +109,33 @@ } + /** + * Verify skip parameter + * + * @throws Exception + */ + public void testSkipConfiguration() + throws Exception + { + File testPom = new File( getBasedir(), + "src/test/resources/unit/custom-configuration/skip-plugin-config.xml" ); + PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom ); + mojo.execute(); + + File basedir = new File( getBasedir(), "target/test/unit/skip-configuration" ); + assertTrue( FileUtils.fileExists( basedir.getAbsolutePath() ) ); + + // verify the generated files do not exist because PMD was skipped + File generatedFile = new File( getBasedir(), "target/test/unit/skip-configuration/target/pmd.csv" ); + assertFalse( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); + + generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/custom.xml" ); + assertFalse( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); + + generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/site/pmd.html" ); + assertFalse( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); + } + public void testInvalidFormat() throws Exception { Added: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/skip-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/skip-plugin-config.xml?rev=418659&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/skip-plugin-config.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/skip-plugin-config.xml Sun Jul 2 15:27:54 2006 @@ -0,0 +1,46 @@ +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>skip.configuration</groupId> + <artifactId>skip-configuration</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <inceptionYear>2006</inceptionYear> + <name>Maven PMD Plugin Skip Configuration Test</name> + <url>http://maven.apache.org</url> + <build> + <finalName>skip-configuration</finalName> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <configuration> + <project implementation="org.apache.maven.plugin.pmd.stubs.CustomConfigurationMavenProjectStub"/> + <outputDirectory>${basedir}/target/test/unit/skip-configuration/target/site</outputDirectory> + <targetDirectory>${basedir}/target/test/unit/skip-configuration/target</targetDirectory> + <format>csv</format> + <linkXRef>true</linkXRef> + <xrefLocation>${basedir}/target/test/unit/skip-configuration/target/site/xref</xrefLocation> + <sourceEncoding>ISO-8859-1</sourceEncoding> + <targetJdk>1.4</targetJdk> + <minimumPriority>4</minimumPriority> + <skip>true</skip> + </configuration> + <dependencies> + <dependency> + <groupId>pmd</groupId> + <artifactId>pmd</artifactId> + <version>3.6</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + </plugins> + </reporting> +</project> Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/custom-configuration/skip-plugin-config.xml ------------------------------------------------------------------------------ svn:eol-style = native