maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r414371 - 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/
Date Wed, 14 Jun 2006 19:51:05 GMT
Author: dennisl
Date: Wed Jun 14 12:51:04 2006
New Revision: 414371

URL: http://svn.apache.org/viewvc?rev=414371&view=rev
Log:
Add PluginConfigurationConverter for maven-jar-plugin

Added:
    maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJar.java
  (with props)
    maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJarTest.java
  (with props)
    maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJarTest.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=414371&r1=414370&r2=414371&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
Wed Jun 14 12:51:04 2006
@@ -26,6 +26,7 @@
 import java.util.Properties;
 
 import org.apache.maven.maven1converter.plugins.PCCCompiler;
+import org.apache.maven.maven1converter.plugins.PCCJar;
 import org.apache.maven.maven1converter.plugins.PCCMultiproject;
 import org.apache.maven.maven1converter.plugins.PCCSurefire;
 import org.apache.maven.maven1converter.plugins.PCCWar;
@@ -67,6 +68,7 @@
      */
     private PluginConfigurationConverter[] converters = new PluginConfigurationConverter[]
{
         new PCCCompiler(),
+        new PCCJar(),
         new PCCSurefire(),
         new PCCMultiproject(),
         new PCCWar() };

Added: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJar.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJar.java?rev=414371&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJar.java
(added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJar.java
Wed Jun 14 12:51:04 2006
@@ -0,0 +1,92 @@
+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-jar-plugin.
+ *
+ * @author Dennis Lundberg
+ * @version $Id: PCCJar.java 409264 2006-05-24 23:13:13 +0000 (on, 24 maj 2006) carlos $
+ */
+public class PCCJar extends AbstractPluginConfigurationConverter
+{
+    /**
+     * @see org.apache.maven.maven1converter.plugins.AbstractPluginConfigurationConverter#getArtifactId()
+     */
+    public String getArtifactId()
+    {
+        return "maven-jar-plugin";
+    }
+
+    public String getType()
+    {
+        return TYPE_BUILD_PLUGIN;
+    }
+
+    protected void buildConfiguration( Xpp3Dom configuration, org.apache.maven.model.v3_0_0.Model
v3Model,
+                                       Properties projectProperties )
+        throws MojoExecutionException
+    {
+        Xpp3Dom archive = new Xpp3Dom( "archive" );
+        addConfigurationChild( archive, projectProperties, "maven.jar.compress", "compress"
);
+        addConfigurationChild( archive, projectProperties, "maven.jar.index", "index" );
+
+        Xpp3Dom manifest = new Xpp3Dom( "manifest" );
+        addConfigurationChild( manifest, projectProperties, "maven.jar.manifest.classpath.add",
"addClasspath" );
+        addConfigurationChild( manifest, projectProperties, "maven.jar.manifest.extensions.add",
"addExtensions" );
+        if ( manifest.getChildCount() > 0 )
+        {
+            archive.addChild( manifest );
+        }
+        addConfigurationChild( manifest, projectProperties, "maven.jar.mainclass", "mainClass"
);
+
+        String manifestEntriesProperty = projectProperties.getProperty( "maven.jar.manifest.attributes.list"
);
+        if ( manifestEntriesProperty != null )
+        {
+            Xpp3Dom manifestEntries = new Xpp3Dom( "manifestEntries" );
+
+            // Loop through property and add values to manifestEntries
+            StringTokenizer tokenizer = new StringTokenizer( manifestEntriesProperty, ","
);
+            while ( tokenizer.hasMoreTokens() )
+            {
+                String attribute = tokenizer.nextToken();
+                addConfigurationChild( manifestEntries, projectProperties, "maven.jar.manifest.attribute."
+ attribute,
+                                       attribute );
+            }
+
+            if ( manifestEntries.getChildCount() > 0 )
+            {
+                archive.addChild( manifestEntries );
+            }
+        }
+
+        addConfigurationChild( archive, projectProperties, "maven.jar.manifest", "manifestFile"
);
+
+        if ( archive.getChildCount() > 0 )
+        {
+            configuration.addChild( archive );
+        }
+
+        addConfigurationChild( configuration, projectProperties, "maven.jar.final.name",
"finalName" );
+    }
+}

Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/main/java/org/apache/maven/maven1converter/plugins/PCCJar.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJarTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJarTest.java?rev=414371&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJarTest.java
(added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/test/java/org/apache/maven/maven1converter/plugins/PCCJarTest.java
Wed Jun 14 12:51:04 2006
@@ -0,0 +1,97 @@
+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: PCCJarTest.java 409264 2006-05-24 23:13:13 +0000 (on, 24 maj 2006) carlos
$
+ */
+public class PCCJarTest extends AbstractPCCTest
+{
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        pluginConfigurationConverter = new PCCJar();
+    }
+
+    public void testBuildConfiguration()
+    {
+        String value;
+
+        try
+        {
+            projectProperties.load( getClassLoader().getResourceAsStream( "PCCJarTest.properties"
) );
+
+            pluginConfigurationConverter.buildConfiguration( configuration, v3Model, projectProperties
);
+
+            Xpp3Dom archive = configuration.getChild( "archive" );
+            if ( archive.getChildCount() > 0 )
+            {
+                value = archive.getChild( "compress" ).getValue();
+                Assert.assertEquals( "check compress value", "false", value );
+
+                value = archive.getChild( "index" ).getValue();
+                Assert.assertEquals( "check index value", "true", value );
+
+                Xpp3Dom manifest = archive.getChild( "manifest" );
+                if ( manifest.getChildCount() > 0 )
+                {
+                    value = manifest.getChild( "addClasspath" ).getValue();
+                    Assert.assertEquals( "check addClasspath value", "true", value );
+
+                    value = manifest.getChild( "addExtensions" ).getValue();
+                    Assert.assertEquals( "check addExtensions value", "true", value );
+
+                    value = manifest.getChild( "mainClass" ).getValue();
+                    Assert.assertEquals( "check mainClass value", "MyClass", value );
+                }
+
+                Xpp3Dom manifestEntries = archive.getChild( "manifestEntries" );
+                if ( manifestEntries.getChildCount() > 0 )
+                {
+                    value = manifestEntries.getChild( "Bar-Attribute" ).getValue();
+                    Assert.assertEquals( "check Bar-Attribute value", "I like toast and jam",
value );
+
+                    value = manifestEntries.getChild( "Foo-Attribute" ).getValue();
+                    Assert.assertEquals( "check Foo-Attribute value", "I like bread and butter",
value );
+                }
+
+                value = archive.getChild( "manifestFile" ).getValue();
+                Assert.assertEquals( "check manifestFile value", "manifest.mf", value );
+            }
+
+            value = configuration.getChild( "finalName" ).getValue();
+            Assert.assertEquals( "check finalName value", "my.jar", 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/PCCJarTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJarTest.properties
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJarTest.properties?rev=414371&view=auto
==============================================================================
--- maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJarTest.properties (added)
+++ maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJarTest.properties Wed
Jun 14 12:51:04 2006
@@ -0,0 +1,24 @@
+#   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.jar.compress=false
+maven.jar.final.name=my.jar
+maven.jar.index=true
+maven.jar.mainclass=MyClass
+maven.jar.manifest=manifest.mf
+maven.jar.manifest.attributes.list=Bar-Attribute,Foo-Attribute
+maven.jar.manifest.attribute.Bar-Attribute=I like toast and jam
+maven.jar.manifest.attribute.Foo-Attribute=I like bread and butter
+maven.jar.manifest.classpath.add=true
+maven.jar.manifest.extensions.add=true

Propchange: maven/sandbox/plugins/maven-maven1-plugin/src/test/resources/PCCJarTest.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message