Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 17821 invoked from network); 6 Dec 2009 16:48:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Dec 2009 16:48:50 -0000 Received: (qmail 89591 invoked by uid 500); 6 Dec 2009 16:48:49 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 89476 invoked by uid 500); 6 Dec 2009 16:48:48 -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 89467 invoked by uid 99); 6 Dec 2009 16:48:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Dec 2009 16:48:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Dec 2009 16:48:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D8C5923888D1; Sun, 6 Dec 2009 16:48:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r887709 - in /maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly: archive/DefaultAssemblyArchiver.java format/FileFormatter.java Date: Sun, 06 Dec 2009 16:48:23 -0000 To: commits@maven.apache.org From: bentmann@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091206164823.D8C5923888D1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bentmann Date: Sun Dec 6 16:48:23 2009 New Revision: 887709 URL: http://svn.apache.org/viewvc?rev=887709&view=rev Log: [MASSEMBLY-456] Usage of archiver or container descriptor handler configuration crashes with LinkageError on Maven 3.0-alpha-5 Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiver.java maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/FileFormatter.java Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiver.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiver.java?rev=887709&r1=887708&r2=887709&view=diff ============================================================================== --- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiver.java (original) +++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/DefaultAssemblyArchiver.java Sun Dec 6 16:48:23 2009 @@ -55,6 +55,7 @@ import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; @@ -67,6 +68,8 @@ import java.io.File; import java.io.IOException; import java.io.StringReader; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -279,9 +282,9 @@ * @param format * Archive format * @param includeBaseDir - * @param configSource * @param finalName - * @param string + * @param configSource + * @param containerHandlers * @return archiver Archiver generated * @throws org.codehaus.plexus.archiver.ArchiverException * @throws org.codehaus.plexus.archiver.manager.NoSuchArchiverException @@ -336,49 +339,29 @@ AssemblerConfigurationSource configSource ) throws InvalidAssemblerConfigurationException { - ComponentConfigurator configurator; - try - { - configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, "basic" ); - } - catch ( ComponentLookupException e ) - { - throw new InvalidAssemblerConfigurationException( "Failed to lookup configurator component for setup of handler: " + handler.getClass().getName(), e ); - } - - XmlPlexusConfiguration configuration = new XmlPlexusConfiguration( config ); - - ConfigurationListener listener = new DebugConfigurationListener( getLogger() ); - ExpressionEvaluator expressionEvaluator = new AssemblyExpressionEvaluator( configSource ); - getLogger().debug( "Configuring handler: '" + handler.getClass().getName() + "' -->" ); - + try { - configurator.configureComponent( handler, configuration, expressionEvaluator, - container.getContainerRealm(), listener ); + configureComponent( handler, config, configSource ); } catch ( ComponentConfigurationException e ) { - throw new InvalidAssemblerConfigurationException( "Failed to configure handler: " + handler.getClass().getName(), e ); + throw new InvalidAssemblerConfigurationException( "Failed to configure handler: " + + handler.getClass().getName(), e ); } - + catch ( ComponentLookupException e ) + { + throw new InvalidAssemblerConfigurationException( "Failed to lookup configurator for setup of handler: " + + handler.getClass().getName(), e ); + } + getLogger().debug( "-- end configuration --" ); } private void configureArchiver( Archiver archiver, AssemblerConfigurationSource configSource ) throws ArchiverException { - ComponentConfigurator configurator; - try - { - configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, "basic" ); - } - catch ( ComponentLookupException e ) - { - throw new ArchiverException( "Failed to lookup configurator component for setup of archiver: " + archiver.getClass().getName(), e ); - } - Xpp3Dom config; try { @@ -392,27 +375,97 @@ { throw new ArchiverException( "Failed to parse archiver configuration for: " + archiver.getClass().getName(), e ); } - - XmlPlexusConfiguration configuration = new XmlPlexusConfiguration( config ); - - ConfigurationListener listener = new DebugConfigurationListener( getLogger() ); - ExpressionEvaluator expressionEvaluator = new AssemblyExpressionEvaluator( configSource ); getLogger().debug( "Configuring archiver: '" + archiver.getClass().getName() + "' -->" ); try { - configurator.configureComponent( archiver, configuration, expressionEvaluator, - container.getContainerRealm(), listener ); + configureComponent( archiver, config, configSource ); } catch ( ComponentConfigurationException e ) { throw new ArchiverException( "Failed to configure archiver: " + archiver.getClass().getName(), e ); } - + catch ( ComponentLookupException e ) + { + throw new ArchiverException( "Failed to lookup configurator for setup of archiver: " + + archiver.getClass().getName(), e ); + } + getLogger().debug( "-- end configuration --" ); } + private void configureComponent( Object component, Xpp3Dom config, AssemblerConfigurationSource configSource ) + throws ComponentLookupException, ComponentConfigurationException + { + ComponentConfigurator configurator = + (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, "basic" ); + + ConfigurationListener listener = new DebugConfigurationListener( getLogger() ); + + ExpressionEvaluator expressionEvaluator = new AssemblyExpressionEvaluator( configSource ); + + XmlPlexusConfiguration configuration = new XmlPlexusConfiguration( config ); + + Object[] containerRealm = getContainerRealm(); + + /* + * NOTE: The signature of configureComponent() has changed in Maven 3.x, the reflection prevents a linkage error + * and makes the code work with both Maven 2 and 3. + */ + try + { + Method configureComponent = + ComponentConfigurator.class.getMethod( "configureComponent", new Class[] { Object.class, + PlexusConfiguration.class, ExpressionEvaluator.class, (Class) containerRealm[1], + ConfigurationListener.class } ); + + configureComponent.invoke( configurator, new Object[] { component, configuration, expressionEvaluator, + containerRealm[0], listener } ); + } + catch ( NoSuchMethodException e ) + { + throw new RuntimeException( e ); + } + catch ( IllegalAccessException e ) + { + throw new RuntimeException( e ); + } + catch ( InvocationTargetException e ) + { + if ( e.getCause() instanceof ComponentConfigurationException ) + { + throw (ComponentConfigurationException) e.getCause(); + } + throw new RuntimeException( e.getCause() ); + } + } + + private Object[] getContainerRealm() + { + /* + * NOTE: The return type of getContainerRealm() has changed in Maven 3.x, the reflection prevents a linkage + * error and makes the code work with both Maven 2 and 3. + */ + try + { + Method getContainerRealm = container.getClass().getMethod( "getContainerRealm", null ); + return new Object[] { getContainerRealm.invoke( container, null ), getContainerRealm.getReturnType() }; + } + catch ( NoSuchMethodException e ) + { + throw new RuntimeException( e ); + } + catch ( IllegalAccessException e ) + { + throw new RuntimeException( e ); + } + catch ( InvocationTargetException e ) + { + throw new RuntimeException( e.getCause() ); + } + } + protected Archiver createWarArchiver() throws NoSuchArchiverException { Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/FileFormatter.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/FileFormatter.java?rev=887709&r1=887708&r2=887709&view=diff ============================================================================== --- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/FileFormatter.java (original) +++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/FileFormatter.java Sun Dec 6 16:48:23 2009 @@ -30,7 +30,6 @@ import java.io.FileReader; import java.io.IOException; import java.io.Reader; -import java.util.Collections; import java.util.Locale; /**