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/16 23:54:50 UTC
svn commit: r414938 - 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 14:54:50 2006
New Revision: 414938
URL: http://svn.apache.org/viewvc?rev=414938&view=rev
Log:
Add PluginConfigurationConverter for maven-checkstyle-plugin
Added:
maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCCheckstyle.java (with props)
maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCCheckstyleTest.java (with props)
maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest1.properties (with props)
maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest2.properties (with props)
maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest3.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=414938&r1=414937&r2=414938&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 14:54:50 2006
@@ -25,6 +25,7 @@
import java.io.Writer;
import java.util.Properties;
+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;
@@ -68,6 +69,7 @@
* Available converters for specific plugin configurations
*/
private PluginConfigurationConverter[] converters = new PluginConfigurationConverter[] {
+ new PCCCheckstyle(),
new PCCCompiler(),
new PCCJar(),
new PCCJavadoc(),
Added: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCCheckstyle.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCCheckstyle.java?rev=414938&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCCheckstyle.java (added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCCheckstyle.java Fri Jun 16 14:54:50 2006
@@ -0,0 +1,115 @@
+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;
+
+/**
+ * A <code>PluginConfigurationConverter</code> for the maven-checkstyle-plugin.
+ *
+ * @author Dennis Lundberg
+ * @version $Id: PCCCheckstyle.java 409264 2006-05-24 23:13:13 +0000 (on, 24 maj 2006) carlos $
+ */
+public class PCCCheckstyle extends AbstractPluginConfigurationConverter
+{
+ /**
+ * @see AbstractPluginConfigurationConverter#getArtifactId()
+ */
+ public String getArtifactId()
+ {
+ return "maven-checkstyle-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.checkstyle.cache.file", "cacheFile" );
+
+ String format = projectProperties.getProperty( "maven.checkstyle.format" );
+ if ( format != null )
+ {
+ String mavenTwoformat = null;
+ if ( format.equals( "avalon" ) )
+ {
+ mavenTwoformat = "config/avalon_checks.xml";
+ }
+ else if ( format.equals( "turbine" ) )
+ {
+ mavenTwoformat = "config/turbine_checks.xml";
+ }
+ else if ( format.equals( "sun" ) )
+ {
+ mavenTwoformat = "config/sun_checks.xml";
+ }
+ if ( mavenTwoformat != null )
+ {
+ addConfigurationChild( configuration, "configLocation", mavenTwoformat );
+ }
+ }
+ else
+ {
+ String propertiesURL = projectProperties.getProperty( "maven.checkstyle.propertiesURL" );
+ if ( propertiesURL != null )
+ {
+ addConfigurationChild( configuration, "configLocation", propertiesURL );
+ }
+ else
+ {
+ addConfigurationChild( configuration, projectProperties, "maven.checkstyle.properties",
+ "configLocation" );
+ }
+ }
+
+ addConfigurationChild( configuration, projectProperties, "maven.checkstyle.excludes", "excludes" );
+
+ addConfigurationChild( configuration, projectProperties, "maven.checkstyle.fail.on.violation", "failsOnError" );
+
+ addConfigurationChild( configuration, projectProperties, "maven.checkstyle.header.file", "headerLocation" );
+
+ addConfigurationChild( configuration, projectProperties, "maven.checkstyle.includes", "includes" );
+
+ String outputText = projectProperties.getProperty( "maven.checkstyle.output.txt" );
+ if ( outputText != null )
+ {
+ addConfigurationChild( configuration, "outputFile", outputText );
+ addConfigurationChild( configuration, "outputFileFormat", "plain" );
+ }
+ else
+ {
+ String outputXml = projectProperties.getProperty( "maven.checkstyle.output.xml" );
+ if ( outputXml != null )
+ {
+ addConfigurationChild( configuration, "outputFile", outputXml );
+ addConfigurationChild( configuration, "outputFileFormat", "xml" );
+ }
+ }
+
+ addConfigurationChild( configuration, projectProperties, "maven.checkstyle.suppressions.file",
+ "suppressionsLocation" );
+
+ addConfigurationChild( configuration, projectProperties, "maven.checkstyle.usefile", "useFile" );
+ }
+}
Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCCheckstyle.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCCheckstyleTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCCheckstyleTest.java?rev=414938&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCCheckstyleTest.java (added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCCheckstyleTest.java Fri Jun 16 14:54:50 2006
@@ -0,0 +1,136 @@
+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 java.io.IOException;
+
+/**
+ * @author Dennis Lundberg
+ * @version $Id: PCCCheckstyleTest.java 409264 2006-05-24 23:13:13 +0000 (on, 24 maj 2006) carlos $
+ */
+public class PCCCheckstyleTest extends AbstractPCCTest
+{
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ pluginConfigurationConverter = new PCCCheckstyle();
+ }
+
+ public void testBuildConfiguration1()
+ {
+ try
+ {
+ projectProperties.load( getClassLoader().getResourceAsStream( "PCCCheckstyleTest1.properties" ) );
+
+ pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
+
+ String value = configuration.getChild( "cacheFile" ).getValue();
+ Assert.assertEquals( "check cacheFile value", "target/checkstyle/myCachefile", value );
+
+ value = configuration.getChild( "configLocation" ).getValue();
+ Assert.assertEquals( "check configLocation value", "config/sun_checks.xml", value );
+
+ value = configuration.getChild( "excludes" ).getValue();
+ Assert.assertEquals( "check excludes value", "**/*.html", value );
+
+ value = configuration.getChild( "failsOnError" ).getValue();
+ Assert.assertEquals( "check failsOnError value", "true", value );
+
+ value = configuration.getChild( "headerLocation" ).getValue();
+ Assert.assertEquals( "check headerLocation value", "src/main/resources/HEADER.txt", value );
+
+ value = configuration.getChild( "includes" ).getValue();
+ Assert.assertEquals( "check includes value", "**/*.java", value );
+
+ value = configuration.getChild( "outputFile" ).getValue();
+ Assert.assertEquals( "check outputFile value", "target/checkstyle/checkstyle-raw-report.txt", value );
+
+ value = configuration.getChild( "outputFileFormat" ).getValue();
+ Assert.assertEquals( "check outputFileFormat value", "plain", value );
+
+ value = configuration.getChild( "suppressionsLocation" ).getValue();
+ Assert.assertEquals( "check suppressionsLocation value", "src/main/resources/mySuppressions.xml", value );
+
+ value = configuration.getChild( "useFile" ).getValue();
+ Assert.assertEquals( "check useFile value", "true", value );
+ }
+ catch ( MojoExecutionException e )
+ {
+ Assert.fail( e.getMessage() );
+ }
+ catch ( IOException e )
+ {
+ Assert.fail( "Unable to find the requested resource." );
+ }
+ }
+
+ public void testBuildConfiguration2()
+ {
+ try
+ {
+ projectProperties.load( getClassLoader().getResourceAsStream( "PCCCheckstyleTest2.properties" ) );
+
+ pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
+
+
+ String value = configuration.getChild( "configLocation" ).getValue();
+ Assert.assertEquals( "check configLocation value",
+ "http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/avalon_checks.xml",
+ value );
+
+ value = configuration.getChild( "outputFile" ).getValue();
+ Assert.assertEquals( "check outputFile value", "target/checkstyle/checkstyle-raw-report.xml", value );
+
+ value = configuration.getChild( "outputFileFormat" ).getValue();
+ Assert.assertEquals( "check outputFileFormat value", "xml", value );
+ }
+ catch ( MojoExecutionException e )
+ {
+ Assert.fail( e.getMessage() );
+ }
+ catch ( IOException e )
+ {
+ Assert.fail( "Unable to find the requested resource." );
+ }
+ }
+
+ public void testBuildConfiguration3()
+ {
+ try
+ {
+ projectProperties.load( getClassLoader().getResourceAsStream( "PCCCheckstyleTest3.properties" ) );
+
+ pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties );
+
+ String value = configuration.getChild( "configLocation" ).getValue();
+ Assert.assertEquals( "check configLocation value", "checkstyle.xml", 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/PCCCheckstyleTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest1.properties
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest1.properties?rev=414938&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest1.properties (added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest1.properties Fri Jun 16 14:54:50 2006
@@ -0,0 +1,25 @@
+# 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.checkstyle.cache.file=target/checkstyle/myCachefile
+maven.checkstyle.excludes=**/*.html
+maven.checkstyle.fail.on.violation=true
+maven.checkstyle.format=sun
+maven.checkstyle.header.file=src/main/resources/HEADER.txt
+maven.checkstyle.includes=**/*.java
+maven.checkstyle.output.txt=target/checkstyle/checkstyle-raw-report.txt
+maven.checkstyle.properties=checkstyle.xml
+maven.checkstyle.propertiesURL=http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/avalon_checks.xml
+maven.checkstyle.suppressions.file=src/main/resources/mySuppressions.xml
+maven.checkstyle.usefile=true
Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest1.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest2.properties
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest2.properties?rev=414938&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest2.properties (added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest2.properties Fri Jun 16 14:54:50 2006
@@ -0,0 +1,17 @@
+# 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.checkstyle.output.xml=target/checkstyle/checkstyle-raw-report.xml
+maven.checkstyle.properties=checkstyle.xml
+maven.checkstyle.propertiesURL=http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/avalon_checks.xml
Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest2.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest3.properties
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest3.properties?rev=414938&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest3.properties (added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest3.properties Fri Jun 16 14:54:50 2006
@@ -0,0 +1,16 @@
+# 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.checkstyle.output.xml=checkstyle-raw-report.xml
+maven.checkstyle.properties=checkstyle.xml
Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCCheckstyleTest3.properties
------------------------------------------------------------------------------
svn:eol-style = native