You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2006/06/17 00:53:12 UTC
svn commit: r414949 - in /maven/sandbox/plugins/maven-maven1-plugin/src:
main/java/org/apache/maven/maven1converter/
main/java/org/apache/maven/maven1converter/plugins/
test/java/org/apache/maven/maven1converter/plugins/ test/resources/
Author: dennisl
Date: Fri Jun 16 15:53:10 2006
New Revision: 414949
URL: http://svn.apache.org/viewvc?rev=414949&view=rev
Log:
Add PluginConfigurationConverter for maven-pmd-plugin
Added:
maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCPmd.java (with props)
maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCPmdTest.java (with props)
maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCPmdTest.properties (with props)
Modified:
maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/PomV3ConvertMojo.java
Modified: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/PomV3ConvertMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/PomV3ConvertMojo.java?rev=414949&r1=414948&r2=414949&view=diff
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/PomV3ConvertMojo.java (original)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/PomV3ConvertMojo.java Fri Jun 16 15:53:10 2006
@@ -16,28 +16,20 @@
* limitations under the License.
*/
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Writer;
-import java.util.Properties;
-
import org.apache.maven.maven1converter.plugins.PCCChanges;
import org.apache.maven.maven1converter.plugins.PCCCheckstyle;
import org.apache.maven.maven1converter.plugins.PCCCompiler;
import org.apache.maven.maven1converter.plugins.PCCJar;
import org.apache.maven.maven1converter.plugins.PCCJavadoc;
import org.apache.maven.maven1converter.plugins.PCCMultiproject;
+import org.apache.maven.maven1converter.plugins.PCCPmd;
import org.apache.maven.maven1converter.plugins.PCCSurefire;
import org.apache.maven.maven1converter.plugins.PCCWar;
import org.apache.maven.maven1converter.plugins.PluginConfigurationConverter;
import org.apache.maven.model.Model;
-import org.apache.maven.model.v3_0_0.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.converter.PomV3ToV4Translator;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
+import org.apache.maven.model.v3_0_0.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -46,6 +38,15 @@
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Writer;
+import java.util.Properties;
+
/**
* Converts a Maven 1 project.xml (v3 pom) to a Maven 2 pom.xml (v4 pom).
* @goal convert
@@ -76,6 +77,7 @@
new PCCJar(),
new PCCJavadoc(),
new PCCMultiproject(),
+ new PCCPmd(),
new PCCSurefire(),
new PCCWar() };
Added: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCPmd.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCPmd.java?rev=414949&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCPmd.java (added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCPmd.java Fri Jun 16 15:53:10 2006
@@ -0,0 +1,96 @@
+package org.apache.maven.maven1converter.plugins;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ * A <code>PluginConfigurationConverter</code> for the maven-pmd-plugin.
+ *
+ * @author Dennis Lundberg
+ * @version $Id: PCCPmd.java 409264 2006-05-24 23:13:13 +0000 (on, 24 maj 2006) carlos $
+ */
+public class PCCPmd extends AbstractPluginConfigurationConverter
+{
+ /**
+ * @see AbstractPluginConfigurationConverter#getArtifactId()
+ */
+ public String getArtifactId()
+ {
+ return "maven-pmd-plugin";
+ }
+
+ public String getType()
+ {
+ return TYPE_REPORT_PLUGIN;
+ }
+
+ protected void buildConfiguration( Xpp3Dom configuration, org.apache.maven.model.v3_0_0.Model v3Model,
+ Properties projectProperties )
+ throws MojoExecutionException
+ {
+ addConfigurationChild( configuration, projectProperties, "maven.pmd.excludes", "excludes" );
+
+ addConfigurationChild( configuration, projectProperties, "maven.pmd.failonruleviolation", "failOnViolation" );
+
+ addConfigurationChild( configuration, projectProperties, "maven.pmd.cpd.minimumtokencount", "minimumTokens" );
+
+ String rulesetfiles = projectProperties.getProperty( "maven.pmd.rulesetfiles" );
+ if ( rulesetfiles != null )
+ {
+ StringTokenizer tokenizer = new StringTokenizer( rulesetfiles, "," );
+ if ( tokenizer.hasMoreTokens() )
+ {
+ Xpp3Dom rulesets = new Xpp3Dom( "rulesets" );
+ while ( tokenizer.hasMoreTokens() )
+ {
+ addConfigurationChild( rulesets, "ruleset", translate( tokenizer.nextToken() ) );
+ }
+ if ( rulesets.getChildCount() > 0 )
+ {
+ configuration.addChild( rulesets );
+ }
+ }
+ }
+
+ addConfigurationChild( configuration, projectProperties, "maven.pmd.targetjdk", "targetJdk" );
+ }
+
+ /**
+ * In the Maven 1 plugin the built-in rulesets where accessed by prefixing
+ * them with "rulesets/", but in the Maven 2 plugin the prefix "/rulesets/"
+ * is used.
+ *
+ * @param mavenOneRuleset A ruleset from the Maven 1 configuration
+ * @return A ruleset suitable for the Maven 2 configuration
+ */
+ private String translate( String mavenOneRuleset )
+ {
+ if ( mavenOneRuleset != null && mavenOneRuleset.startsWith( "rulesets/" ) )
+ {
+ return "/" + mavenOneRuleset;
+ }
+ else
+ {
+ return mavenOneRuleset;
+ }
+ }
+}
Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCPmd.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCPmdTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCPmdTest.java?rev=414949&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCPmdTest.java (added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCPmdTest.java Fri Jun 16 15:53:10 2006
@@ -0,0 +1,86 @@
+package org.apache.maven.maven1converter.plugins;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import junit.framework.Assert;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+import java.io.IOException;
+
+/**
+ * @author Dennis Lundberg
+ * @version $Id: PCCPmdTest.java 409264 2006-05-24 23:13:13 +0000 (on, 24 maj 2006) carlos $
+ */
+public class PCCPmdTest extends AbstractPCCTest
+{
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ pluginConfigurationConverter = new PCCPmd();
+ }
+
+ public void testBuildConfiguration()
+ {
+ try
+ {
+ projectProperties.load( getClassLoader().getResourceAsStream( "PCCPmdTest.properties" ) );
+
+ pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
+
+ String value = configuration.getChild( "excludes" ).getValue();
+ Assert.assertEquals( "check excludes value", "**/*PropertyListParser*", value );
+
+ value = configuration.getChild( "failOnViolation" ).getValue();
+ Assert.assertEquals( "check failOnViolation value", "true", value );
+
+ value = configuration.getChild( "minimumTokens" ).getValue();
+ Assert.assertEquals( "check minimumTokens value", "50", value );
+
+ Xpp3Dom rulesets = configuration.getChild( "rulesets" );
+ if ( rulesets.getChildCount() == 3 )
+ {
+ Xpp3Dom rulesetOne = rulesets.getChild( 0 );
+ Assert.assertEquals( "check rulesets/ruleset value", "fileupload_basic.xml", rulesetOne.getValue() );
+
+ Xpp3Dom rulesetTwo = rulesets.getChild( 1 );
+ Assert.assertEquals( "check rulesets/ruleset value", "/rulesets/unusedcode.xml",
+ rulesetTwo.getValue() );
+
+ Xpp3Dom rulesetThree = rulesets.getChild( 2 );
+ Assert.assertEquals( "check rulesets/ruleset value", "/rulesets/imports.xml", rulesetThree.getValue() );
+ }
+ else
+ {
+ Assert.fail( "Wrong number of ruleset elements" );
+ }
+
+ value = configuration.getChild( "targetJdk" ).getValue();
+ Assert.assertEquals( "check targetJdk value", "1.4", value );
+ }
+ catch ( MojoExecutionException e )
+ {
+ Assert.fail( e.getMessage() );
+ }
+ catch ( IOException e )
+ {
+ Assert.fail( "Unable to find the requested resource." );
+ }
+ }
+}
Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCPmdTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCPmdTest.properties
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCPmdTest.properties?rev=414949&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCPmdTest.properties (added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCPmdTest.properties Fri Jun 16 15:53:10 2006
@@ -0,0 +1,19 @@
+# Copyright 2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+maven.pmd.cpd.minimumtokencount=50
+maven.pmd.excludes=**/*PropertyListParser*
+maven.pmd.failonruleviolation=true
+maven.pmd.rulesetfiles=fileupload_basic.xml,rulesets/unusedcode.xml,rulesets/imports.xml
+maven.pmd.targetjdk=1.4
Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCPmdTest.properties
------------------------------------------------------------------------------
svn:eol-style = native