Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 6680 invoked from network); 14 Jun 2006 19:51:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Jun 2006 19:51:29 -0000 Received: (qmail 25886 invoked by uid 500); 14 Jun 2006 19:51:28 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 25796 invoked by uid 500); 14 Jun 2006 19:51:28 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 25775 invoked by uid 99); 14 Jun 2006 19:51:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Jun 2006 12:51:27 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Jun 2006 12:51:26 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 6FB201A983A; Wed, 14 Jun 2006 12:51:06 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@maven.apache.org From: dennisl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060614195106.6FB201A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 PluginConfigurationConverter 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