You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2010/09/21 22:34:53 UTC

svn commit: r999612 [3/10] - in /maven/plugins/trunk/maven-assembly-plugin: ./ src/main/java/org/apache/maven/plugin/assembly/ src/main/java/org/apache/maven/plugin/assembly/archive/ src/main/java/org/apache/maven/plugin/assembly/archive/archiver/ src/...

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddDirectoryTask.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddDirectoryTask.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddDirectoryTask.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddDirectoryTask.java Tue Sep 21 20:34:50 2010
@@ -19,17 +19,17 @@ package org.apache.maven.plugin.assembly
  * under the License.
  */
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
 import org.apache.maven.plugin.assembly.archive.ArchiveCreationException;
 import org.codehaus.plexus.archiver.Archiver;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.util.DefaultFileSet;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
 /**
  * @version $Id$
  */
@@ -39,9 +39,9 @@ public class AddDirectoryTask
 
     private final File directory;
 
-    private List includes;
+    private List<String> includes;
 
-    private List excludes;
+    private List<String> excludes;
 
     private String outputDirectory;
 
@@ -51,12 +51,12 @@ public class AddDirectoryTask
 
     private int fileMode = -1;
 
-    public AddDirectoryTask( File directory )
+    public AddDirectoryTask( final File directory )
     {
         this.directory = directory;
     }
 
-    public void execute( Archiver archiver, AssemblerConfigurationSource configSource )
+    public void execute( final Archiver archiver, final AssemblerConfigurationSource configSource )
         throws ArchiveCreationException
     {
         if ( ".".equals( outputDirectory ) )
@@ -66,15 +66,15 @@ public class AddDirectoryTask
         else if ( "..".equals( outputDirectory ) )
         {
             throw new ArchiveCreationException( "Cannot add source directory: " + directory + " to archive-path: "
-                + outputDirectory + ". All paths must be within the archive root directory." );
+                            + outputDirectory + ". All paths must be within the archive root directory." );
         }
-        
-        int oldDirMode = archiver.getOverrideDirectoryMode();
-        int oldFileMode = archiver.getOverrideFileMode();
+
+        final int oldDirMode = archiver.getOverrideDirectoryMode();
+        final int oldFileMode = archiver.getOverrideFileMode();
 
         boolean fileModeSet = false;
         boolean dirModeSet = false;
-        
+
         try
         {
             if ( directoryMode != -1 )
@@ -91,14 +91,14 @@ public class AddDirectoryTask
 
             if ( directory.exists() )
             {
-                List directoryExcludes;
+                List<String> directoryExcludes;
                 if ( excludes != null && !excludes.isEmpty() )
                 {
-                    directoryExcludes = new ArrayList( excludes );
+                    directoryExcludes = new ArrayList<String>( excludes );
                 }
                 else
                 {
-                    directoryExcludes = new ArrayList();
+                    directoryExcludes = new ArrayList<String>();
                 }
 
                 try
@@ -107,50 +107,50 @@ public class AddDirectoryTask
                     if ( includes != null && !includes.isEmpty() )
                     {
                         includesArray = new String[includes.size()];
-                        
+
                         int i = 0;
-                        for ( Iterator it = includes.iterator(); it.hasNext(); )
+                        for ( final Iterator<String> it = includes.iterator(); it.hasNext(); )
                         {
-                            String value = (String) it.next();
+                            String value = it.next();
                             if ( value.startsWith( "./" ) || value.startsWith( ".\\" ) )
                             {
                                 value = value.substring( 2 );
                             }
-                            
+
                             if ( value.startsWith( "/" ) || value.startsWith( "\\" ) )
                             {
                                 value = value.substring( 1 );
                             }
-                            
+
                             includesArray[i] = value;
-                            
+
                             i++;
                         }
                     }
 
                     // this one is guaranteed to be non-null by code above.
-                    String[] excludesArray = new String[directoryExcludes.size()];
-                    
+                    final String[] excludesArray = new String[directoryExcludes.size()];
+
                     int i = 0;
-                    for ( Iterator it = directoryExcludes.iterator(); it.hasNext(); )
+                    for ( final Iterator<String> it = directoryExcludes.iterator(); it.hasNext(); )
                     {
-                        String value = (String) it.next();
+                        String value = it.next();
                         if ( value.startsWith( "./" ) || value.startsWith( ".\\" ) )
                         {
                             value = value.substring( 2 );
                         }
-                        
+
                         if ( value.startsWith( "/" ) || value.startsWith( "\\" ) )
                         {
                             value = value.substring( 1 );
                         }
-                        
+
                         excludesArray[i] = value;
-                        
+
                         i++;
                     }
 
-                    DefaultFileSet fs = new DefaultFileSet();
+                    final DefaultFileSet fs = new DefaultFileSet();
                     fs.setUsingDefaultExcludes( useDefaultExcludes );
                     fs.setPrefix( outputDirectory );
                     fs.setDirectory( directory );
@@ -159,7 +159,7 @@ public class AddDirectoryTask
 
                     archiver.addFileSet( fs );
                 }
-                catch ( ArchiverException e )
+                catch ( final ArchiverException e )
                 {
                     throw new ArchiveCreationException( "Error adding directory to archive: " + e.getMessage(), e );
                 }
@@ -171,7 +171,7 @@ public class AddDirectoryTask
             {
                 archiver.setDirectoryMode( oldDirMode );
             }
-            
+
             if ( fileModeSet )
             {
                 archiver.setFileMode( oldFileMode );
@@ -179,32 +179,32 @@ public class AddDirectoryTask
         }
     }
 
-    public void setExcludes( List excludes )
+    public void setExcludes( final List<String> excludes )
     {
         this.excludes = excludes;
     }
 
-    public void setIncludes( List includes )
+    public void setIncludes( final List<String> includes )
     {
         this.includes = includes;
     }
 
-    public void setOutputDirectory( String outputDirectory )
+    public void setOutputDirectory( final String outputDirectory )
     {
         this.outputDirectory = outputDirectory;
     }
 
-    public void setDirectoryMode( int directoryMode )
+    public void setDirectoryMode( final int directoryMode )
     {
         this.directoryMode = directoryMode;
     }
 
-    public void setFileMode( int fileMode )
+    public void setFileMode( final int fileMode )
     {
         this.fileMode = fileMode;
     }
 
-    public void setUseDefaultExcludes( boolean useDefaultExcludes )
+    public void setUseDefaultExcludes( final boolean useDefaultExcludes )
     {
         this.useDefaultExcludes = useDefaultExcludes;
     }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java Tue Sep 21 20:34:50 2010
@@ -43,20 +43,20 @@ public class AddFileSetsTask
     implements ArchiverTask
 {
 
-    private final List fileSets;
+    private final List<FileSet> fileSets;
 
     private Logger logger;
 
     private MavenProject project;
-    
+
     private MavenProject moduleProject;
 
-    public AddFileSetsTask( List fileSets )
+    public AddFileSetsTask( final List<FileSet> fileSets )
     {
         this.fileSets = fileSets;
     }
 
-    public void execute( Archiver archiver, AssemblerConfigurationSource configSource )
+    public void execute( final Archiver archiver, final AssemblerConfigurationSource configSource )
         throws ArchiveCreationException, AssemblyFormattingException
     {
         // don't need this check here. it's more efficient here, but the logger is not actually
@@ -64,45 +64,45 @@ public class AddFileSetsTask
         // class.
         // checkLogger();
 
-        File archiveBaseDir = configSource.getArchiveBaseDirectory();
+        final File archiveBaseDir = configSource.getArchiveBaseDirectory();
 
         if ( archiveBaseDir != null )
         {
             if ( !archiveBaseDir.exists() )
             {
                 throw new ArchiveCreationException( "The archive base directory '" + archiveBaseDir.getAbsolutePath()
-                    + "' does not exist" );
+                                + "' does not exist" );
             }
             else if ( !archiveBaseDir.isDirectory() )
             {
                 throw new ArchiveCreationException( "The archive base directory '" + archiveBaseDir.getAbsolutePath()
-                    + "' exists, but it is not a directory" );
+                                + "' exists, but it is not a directory" );
             }
         }
 
-        for ( Iterator i = fileSets.iterator(); i.hasNext(); )
+        for ( final Iterator<FileSet> i = fileSets.iterator(); i.hasNext(); )
         {
-            FileSet fileSet = (FileSet) i.next();
+            final FileSet fileSet = i.next();
 
             addFileSet( fileSet, archiver, configSource, archiveBaseDir );
         }
     }
 
-    protected void addFileSet( FileSet fileSet, Archiver archiver, AssemblerConfigurationSource configSource,
-                               File archiveBaseDir )
+    protected void addFileSet( final FileSet fileSet, final Archiver archiver,
+                               final AssemblerConfigurationSource configSource, final File archiveBaseDir )
         throws AssemblyFormattingException, ArchiveCreationException
     {
         // throw this check in just in case someone extends this class...
         checkLogger();
 
-        FileSetFormatter fileSetFormatter = new FileSetFormatter( configSource, logger );
+        final FileSetFormatter fileSetFormatter = new FileSetFormatter( configSource, logger );
 
         if ( project == null )
         {
             project = configSource.getProject();
         }
 
-        File basedir = project.getBasedir();
+        final File basedir = project.getBasedir();
 
         String destDirectory = fileSet.getOutputDirectory();
 
@@ -118,9 +118,9 @@ public class AddFileSetsTask
         if ( logger.isDebugEnabled() )
         {
             logger.debug( "FileSet[" + destDirectory + "]" + " dir perms: "
-                + Integer.toString( archiver.getOverrideDirectoryMode(), 8 ) + " file perms: "
-                + Integer.toString( archiver.getOverrideFileMode(), 8 )
-                + ( fileSet.getLineEnding() == null ? "" : " lineEndings: " + fileSet.getLineEnding() ) );
+                            + Integer.toString( archiver.getOverrideDirectoryMode(), 8 ) + " file perms: "
+                            + Integer.toString( archiver.getOverrideFileMode(), 8 )
+                            + ( fileSet.getLineEnding() == null ? "" : " lineEndings: " + fileSet.getLineEnding() ) );
         }
 
         logger.debug( "The archive base directory is '" + archiveBaseDir + "'" );
@@ -133,35 +133,36 @@ public class AddFileSetsTask
             {
                 fileSetDir = fileSetFormatter.formatFileSetForAssembly( fileSetDir, fileSet );
             }
-            catch ( IOException e )
+            catch ( final IOException e )
             {
                 throw new ArchiveCreationException( "Error fixing file-set line endings for assembly: "
-                    + e.getMessage(), e );
+                                + e.getMessage(), e );
             }
 
-            logger.debug( "Adding file-set from directory: '" + fileSetDir.getAbsolutePath() + "'\nassembly output directory is: \'" + destDirectory + "\'" );
+            logger.debug( "Adding file-set from directory: '" + fileSetDir.getAbsolutePath()
+                            + "'\nassembly output directory is: \'" + destDirectory + "\'" );
 
-            AddDirectoryTask task = new AddDirectoryTask( fileSetDir );
+            final AddDirectoryTask task = new AddDirectoryTask( fileSetDir );
 
-            int dirMode = TypeConversionUtils.modeToInt( fileSet.getDirectoryMode(), logger );
+            final int dirMode = TypeConversionUtils.modeToInt( fileSet.getDirectoryMode(), logger );
             if ( dirMode != -1 )
             {
                 task.setDirectoryMode( dirMode );
             }
-            
-            int fileMode = TypeConversionUtils.modeToInt( fileSet.getFileMode(), logger );
+
+            final int fileMode = TypeConversionUtils.modeToInt( fileSet.getFileMode(), logger );
             if ( fileMode != -1 )
             {
                 task.setFileMode( fileMode );
             }
-            
+
             task.setUseDefaultExcludes( fileSet.isUseDefaultExcludes() );
-            
-            List excludes = fileSet.getExcludes();
+
+            final List<String> excludes = fileSet.getExcludes();
             excludes.add( "**/*.filtered" );
             excludes.add( "**/*.formatted" );
             task.setExcludes( excludes );
-            
+
             task.setIncludes( fileSet.getIncludes() );
             task.setOutputDirectory( destDirectory );
 
@@ -169,12 +170,13 @@ public class AddFileSetsTask
         }
     }
 
-    protected File getFileSetDirectory( FileSet fileSet, File basedir, File archiveBaseDir )
+    protected File getFileSetDirectory( final FileSet fileSet, final File basedir, final File archiveBaseDir )
         throws ArchiveCreationException, AssemblyFormattingException
     {
         String sourceDirectory = fileSet.getDirectory();
 
-        if ( sourceDirectory == null || sourceDirectory.trim().length() < 1 )
+        if ( sourceDirectory == null || sourceDirectory.trim()
+                                                       .length() < 1 )
         {
             sourceDirectory = basedir.getAbsolutePath();
         }
@@ -206,12 +208,12 @@ public class AddFileSetsTask
         }
     }
 
-    public void setLogger( Logger logger )
+    public void setLogger( final Logger logger )
     {
         this.logger = logger;
     }
 
-    public void setProject( MavenProject project )
+    public void setProject( final MavenProject project )
     {
         this.project = project;
     }
@@ -221,7 +223,7 @@ public class AddFileSetsTask
         return moduleProject;
     }
 
-    public void setModuleProject( MavenProject moduleProject )
+    public void setModuleProject( final MavenProject moduleProject )
     {
         this.moduleProject = moduleProject;
     }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DefaultDependencyResolver.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DefaultDependencyResolver.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DefaultDependencyResolver.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DefaultDependencyResolver.java Tue Sep 21 20:34:50 2010
@@ -19,16 +19,6 @@ package org.apache.maven.plugin.assembly
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -38,15 +28,10 @@ import org.apache.maven.artifact.resolve
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.resolver.DebugResolutionListener;
+import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.DependencyManagement;
-import org.apache.maven.model.Exclusion;
 import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
+import org.apache.maven.plugin.assembly.AssemblyContext;
 import org.apache.maven.plugin.assembly.archive.ArchiveCreationException;
 import org.apache.maven.plugin.assembly.archive.phase.ModuleSetAssemblyPhase;
 import org.apache.maven.plugin.assembly.model.Assembly;
@@ -57,40 +42,39 @@ import org.apache.maven.plugin.assembly.
 import org.apache.maven.plugin.assembly.utils.FilterUtils;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
-import org.apache.maven.project.artifact.MavenMetadataSource;
-import org.apache.maven.shared.artifact.filter.ScopeArtifactFilter;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.util.StringUtils;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
 /**
- * @plexus.component role="org.apache.maven.plugin.assembly.artifact.DependencyResolver" role-hint="default"
- *
  * @author jdcasey
  * @version $Id$
  */
+@Component( role = DependencyResolver.class )
 public class DefaultDependencyResolver
-    extends AbstractLogEnabled implements DependencyResolver
+    extends AbstractLogEnabled
+    implements DependencyResolver
 {
-    
-    /**
-     * @plexus.requirement
-     */
+
+    @Requirement
     private ArtifactResolver resolver;
 
-    /**
-     * @plexus.requirement
-     */
+    @Requirement
     private ArtifactMetadataSource metadataSource;
 
-    /**
-     * @plexus.requirement
-     */
+    @Requirement
     private ArtifactFactory factory;
-    
-    /**
-     * @plexus.requirement
-     */
+
+    @Requirement
     private ArtifactCollector collector;
 
     public DefaultDependencyResolver()
@@ -98,8 +82,9 @@ public class DefaultDependencyResolver
         // for plexus init
     }
 
-    protected DefaultDependencyResolver( ArtifactResolver resolver, ArtifactMetadataSource metadataSource,
-                               ArtifactFactory factory, ArtifactCollector collector, Logger logger )
+    protected DefaultDependencyResolver( final ArtifactResolver resolver, final ArtifactMetadataSource metadataSource,
+                                         final ArtifactFactory factory, final ArtifactCollector collector,
+                                         final Logger logger )
     {
         this.resolver = resolver;
         this.metadataSource = metadataSource;
@@ -109,391 +94,248 @@ public class DefaultDependencyResolver
         enableLogging( logger );
     }
 
-    public Map buildManagedVersionMap( Assembly assembly, AssemblerConfigurationSource configSource )
-        throws ArchiveCreationException, InvalidVersionSpecificationException, InvalidDependencyVersionException,
-        ArtifactResolutionException
-    {
-        MavenProject currentProject = configSource.getProject();
-        
-        ResolutionManagementInfo depInfo = new ResolutionManagementInfo( currentProject );
-        
-        getDependencySetResolutionRequirements( assembly.getDependencySets(), depInfo );
-        getModuleSetResolutionRequirements( assembly.getModuleSets(), depInfo, configSource );
-        getRepositoryResolutionRequirements( assembly.getRepositories(), depInfo );
-        
-        if ( !depInfo.isResolutionRequired() )
-        {
-            return new HashMap();
-        }
-        
-        Map managedVersions = new HashMap();
-        Set allRequiredArtifacts = new LinkedHashSet();
-        List allRemoteRepos = new ArrayList();
-        
-        for ( Iterator it = depInfo.getEnabledProjects().iterator(); it.hasNext(); )
-        {
-            MavenProject project = (MavenProject) it.next();
-            
-            Map projectManagedVersions = getManagedVersionMap( project );
-            if ( projectManagedVersions != null )
-            {
-                for ( Iterator versionIterator = projectManagedVersions.keySet().iterator(); versionIterator.hasNext(); )
-                {
-                    String id = (String) versionIterator.next();
-                    if ( !managedVersions.containsKey( id ) )
-                    {
-                        managedVersions.put( id, projectManagedVersions.get( id ) );
-                    }
-                }
-            }
-        }
-        
-        if ( configSource.getRemoteRepositories() != null && !configSource.getRemoteRepositories().isEmpty() )
-        {
-            allRemoteRepos.addAll( configSource.getRemoteRepositories() );
-        }
-        
-        for ( Iterator it = depInfo.getEnabledProjects().iterator(); it.hasNext(); )
-        {
-            MavenProject project = (MavenProject) it.next();
-            
-            allRequiredArtifacts.addAll( MavenMetadataSource.createArtifacts( factory, project.getDependencies(), null,
-                                                                              depInfo.getScopeFilter(), project ) );
-            
-            allRemoteRepos = aggregateRemoteArtifactRepositories( allRemoteRepos, project );
-        }
-        
-        if ( depInfo.isResolvedTransitively() )
-        {
-            // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
-            Artifact projectArtifact =
-                factory.createBuildArtifact( currentProject.getGroupId(), currentProject.getArtifactId()
-                    + "-[assembly process]", currentProject.getVersion(), currentProject.getPackaging() );
-
-            List listeners =
-                getLogger().isDebugEnabled() ? Collections.singletonList( new DebugResolutionListener( getLogger() ) )
-                                : Collections.EMPTY_LIST;
-            
-            ArtifactResolutionResult resolutionResult =
-                collector.collect( allRequiredArtifacts, projectArtifact, managedVersions,
-                                   configSource.getLocalRepository(), allRemoteRepos, metadataSource,
-                                   depInfo.getScopeFilter(), listeners );
-            
-            Set artifacts = resolutionResult.getArtifacts();
-            if ( artifacts != null )
-            {
-                for ( Iterator versionIterator = artifacts.iterator(); versionIterator.hasNext(); )
-                {
-                    Artifact artifact = (Artifact) versionIterator.next();
-                    String id = artifact.getDependencyConflictId();
-                    if ( !managedVersions.containsKey( id ) )
-                    {
-                        managedVersions.put( id, artifact );
-                    }
-                }
-            }
-        }
-        else
+    public void resolve( final Assembly assembly, final AssemblerConfigurationSource configSource,
+                         final AssemblyContext context )
+        throws DependencyResolutionException
+    {
+        final MavenProject currentProject = configSource.getProject();
+
+        final ResolutionManagementInfo info = new ResolutionManagementInfo( currentProject );
+        getRepositoryResolutionRequirements( assembly, info, currentProject );
+        getDependencySetResolutionRequirements( assembly, assembly.getDependencySets(), info, currentProject );
+        getModuleSetResolutionRequirements( assembly, info, configSource );
+
+        if ( !info.isResolutionRequired() )
         {
-            if ( allRequiredArtifacts != null )
-            {
-                for ( Iterator versionIterator = allRequiredArtifacts.iterator(); versionIterator.hasNext(); )
-                {
-                    Artifact artifact = (Artifact) versionIterator.next();
-                    if ( artifact.getVersion() == null )
-                    {
-                        if ( getLogger().isDebugEnabled() )
-                        {
-                            getLogger().debug(
-                                              "Not sure what to do with the version range: "
-                                                  + artifact.getVersionRange()
-                                                  + " in non-transitive mode, encountered while building managed versions collection; skipping it for now. Artifact: "
-                                                  + artifact );
-                        }
-                        
-                        continue;
-                    }
-                    
-                    String id = artifact.getDependencyConflictId();
-                    if ( !managedVersions.containsKey( id ) )
-                    {
-                        managedVersions.put( id, artifact );
-                    }
-                }
-            }
-        }
-        
-        return managedVersions;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.maven.plugin.assembly.artifact.DependencyResolver#resolveDependencies(org.apache.maven.project.MavenProject, java.lang.String, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List)
-     */
-    public Set resolveDependencies( MavenProject project, String scope, Map managedVersions, ArtifactRepository localRepository,
-                                    List remoteRepositories, boolean resolveTransitively )
-        throws InvalidDependencyVersionException, ArtifactResolutionException, ArtifactNotFoundException
-    {
-        List repos = aggregateRemoteArtifactRepositories( remoteRepositories, project );
-
-        ArtifactFilter filter = new ScopeArtifactFilter( scope );
-
-        // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
-        Artifact artifact =
-            factory.createBuildArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(),
-                                         project.getPackaging() );
-
-        Set dependencyArtifacts =
-            MavenMetadataSource.createArtifacts( factory, project.getDependencies(), null, filter, project );
-
-        getLogger().debug(
-                           "Dependencies for project: " + project.getId() + " are:\n"
-                               + StringUtils.join( dependencyArtifacts.iterator(), "\n" ) );
-        
-        for ( Iterator it = dependencyArtifacts.iterator(); it.hasNext(); )
-        {
-            Artifact depArtifact = (Artifact) it.next();
-            
-            if ( managedVersions.containsKey( depArtifact.getDependencyConflictId() ) )
-            {
-                manageArtifact( depArtifact, managedVersions );
-            }
+            context.setResolvedArtifacts( new HashSet<Artifact>() );
+            return;
         }
 
-        if ( resolveTransitively )
+        final List<ArtifactRepository> repos =
+            aggregateRemoteArtifactRepositories( configSource.getRemoteRepositories(), info.getEnabledProjects() );
+
+        Set<Artifact> artifacts = info.getArtifacts();
+        if ( info.isResolvedTransitively() )
         {
             getLogger().debug( "Resolving project dependencies transitively." );
-            return resolveTransitively( dependencyArtifacts, artifact, managedVersions, localRepository, repos, filter, project );
+            artifacts = resolveTransitively( artifacts, repos, info, configSource );
         }
         else
         {
             getLogger().debug( "Resolving project dependencies ONLY. Transitive dependencies WILL NOT be included in the results." );
-            return resolveNonTransitively( dependencyArtifacts, artifact, managedVersions, localRepository, repos, filter );
-        }
-    }
-
-    protected Set resolveNonTransitively( Set dependencyArtifacts, Artifact artifact, Map managedVersions,
-                                          ArtifactRepository localRepository, List repos, ArtifactFilter filter )
-        throws ArtifactResolutionException, ArtifactNotFoundException
-    {
-        for ( Iterator it = dependencyArtifacts.iterator(); it.hasNext(); )
-        {
-            Artifact depArtifact = (Artifact) it.next();
-            
-            resolver.resolve( depArtifact, repos, localRepository );
+            artifacts = resolveNonTransitively( assembly, artifacts, configSource, repos );
         }
 
-        return dependencyArtifacts;
+        context.setResolvedArtifacts( artifacts );
     }
 
-    private Set resolveTransitively( Set dependencyArtifacts, Artifact artifact, Map managedVersions, ArtifactRepository localRepository,
-                                     List repos, ArtifactFilter filter, MavenProject project )
-        throws InvalidDependencyVersionException, ArtifactResolutionException, ArtifactNotFoundException
+    protected Set<Artifact> resolveNonTransitively( final Assembly assembly, final Set<Artifact> dependencyArtifacts,
+                                                    final AssemblerConfigurationSource configSource,
+                                                    final List<ArtifactRepository> repos )
+        throws DependencyResolutionException
     {
-        ArtifactResolutionResult result =
-            resolver.resolveTransitively( dependencyArtifacts, artifact, managedVersions, localRepository, repos,
-                                          metadataSource, filter );
-
-        getLogger().debug( "While resolving dependencies of " + project.getId() + ":" );
-
-        FilterUtils.reportFilteringStatistics( Collections.singleton( filter ), getLogger() );
 
-        return result.getArtifacts();
-    }
-
-    // Copied from DefaultArtifactCollector, SVN: http://svn.apache.org/repos/asf/maven/components/branches/maven-2.1.x@679206
-    // with modifications to work with non-transitive resolution processes. 
-    protected void manageArtifact( Artifact targetArtifact, Map managedVersions )
-    {
-        Artifact artifact = (Artifact) managedVersions.get( targetArtifact.getDependencyConflictId() );
-        
-        if ( artifact == null )
+        final List<Artifact> missing = new ArrayList<Artifact>();
+        final Set<Artifact> resolved = new HashSet<Artifact>();
+        for ( final Iterator<Artifact> it = dependencyArtifacts.iterator(); it.hasNext(); )
         {
-            return;
-        }
+            final Artifact depArtifact = it.next();
 
-        // Before we update the version of the artifact, we need to know
-        // whether we are working on a transitive dependency or not.  This
-        // allows depMgmt to always override transitive dependencies, while
-        // explicit child override depMgmt (viz. depMgmt should only
-        // provide defaults to children, but should override transitives).
-        // We can do this by calling isChildOfRootNode on the current node.
-
-        if ( artifact.getVersion() != null )
-        {
-            if ( getLogger().isDebugEnabled() )
+            try
             {
-                getLogger().debug( "Managing version for: " + targetArtifact.getDependencyConflictId() + " to: " + artifact.getVersion() );
+                resolver.resolve( depArtifact, repos, configSource.getLocalRepository() );
+                resolved.add( depArtifact );
             }
-            
-            targetArtifact.setVersion( artifact.getVersion() );
-        }
-
-        if ( artifact.getScope() != null )
-        {
-            if ( getLogger().isDebugEnabled() )
+            catch ( final ArtifactResolutionException e )
             {
-                getLogger().debug( "Managing scope for: " + targetArtifact.getDependencyConflictId() + " to: " + artifact.getScope() );
+                if ( getLogger().isDebugEnabled() )
+                {
+                    getLogger().debug( "Failed to resolve: " + depArtifact.getId() + " for assembly: "
+                                                       + assembly.getId() );
+                }
+                missing.add( depArtifact );
             }
-            
-            targetArtifact.setScope( artifact.getScope() );
-        }
-    }
-    
-    protected List aggregateRemoteArtifactRepositories( List remoteRepositories, MavenProject project )
-    {
-        List repoLists = new ArrayList();
-
-        repoLists.add( remoteRepositories );
-        repoLists.add( project.getRemoteArtifactRepositories() );
-
-        List remoteRepos = new ArrayList();
-        Set encounteredUrls = new HashSet();
-
-        for ( Iterator listIterator = repoLists.iterator(); listIterator.hasNext(); )
-        {
-            List repositoryList = ( List ) listIterator.next();
-
-            if ( ( repositoryList != null ) && !repositoryList.isEmpty() )
+            catch ( final ArtifactNotFoundException e )
             {
-                for ( Iterator it = repositoryList.iterator(); it.hasNext(); )
+                if ( getLogger().isDebugEnabled() )
                 {
-                    ArtifactRepository repo = ( ArtifactRepository ) it.next();
-
-                    if ( !encounteredUrls.contains( repo.getUrl() ) )
-                    {
-                        remoteRepos.add( repo );
-                        encounteredUrls.add( repo.getUrl() );
-                    }
+                    getLogger().debug( "Failed to resolve: " + depArtifact.getId() + " for assembly: "
+                                                       + assembly.getId() );
                 }
+                missing.add( depArtifact );
             }
         }
 
-        return remoteRepos;
-    }
+        if ( !missing.isEmpty() )
+        {
+            final MavenProject project = configSource.getProject();
+            final Artifact rootArtifact = project.getArtifact();
 
-    // TODO: Remove this, once we can depend on Maven 2.0.7 or later...in which
-    // MavenProject.getManagedVersionMap() exists. This is from MNG-1577.
-    protected Map getManagedVersionMap( MavenProject project )
-        throws InvalidVersionSpecificationException
-    {
-        DependencyManagement dependencyManagement = project.getModel().getDependencyManagement();
+            final Throwable error =
+                new MultipleArtifactsNotFoundException( rootArtifact, new ArrayList<Artifact>( resolved ), missing,
+                                                        repos );
 
-        Map map = null;
-        List deps;
-        if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null )
-             && ( deps.size() > 0 ) )
-        {
-            map = new HashMap();
+            throw new DependencyResolutionException( "Failed to resolve dependencies for: " + assembly.getId(), error );
+        }
 
-            if ( getLogger().isDebugEnabled() )
-            {
-                getLogger().debug( "Adding managed dependencies for " + project.getId() );
-            }
+        return resolved;
+    }
 
-            for ( Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext(); )
-            {
-                Dependency d = (Dependency) i.next();
+    @SuppressWarnings( "unchecked" )
+    private Set<Artifact> resolveTransitively( final Set<Artifact> dependencyArtifacts,
+                                               final List<ArtifactRepository> repos,
+                                               final ResolutionManagementInfo info,
+                                               final AssemblerConfigurationSource configSource )
+        throws DependencyResolutionException
+    {
+        final MavenProject project = configSource.getProject();
 
-                VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
-                Artifact artifact = factory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
-                                                                              versionRange, d.getType(),
-                                                                              d.getClassifier(), d.getScope(),
-                                                                              d.isOptional() );
-                if ( getLogger().isDebugEnabled() )
-                {
-                    getLogger().debug( "  " + artifact );
-                }
+        final ArtifactFilter filter = info.getScopeFilter();
+        final ArtifactRepository localRepository = configSource.getLocalRepository();
 
-                // If the dependencyManagement section listed exclusions,
-                // add them to the managed artifacts here so that transitive
-                // dependencies will be excluded if necessary.
-                if ( ( null != d.getExclusions() ) && !d.getExclusions().isEmpty() )
-                {
-                    List exclusions = new ArrayList();
-                    Iterator exclItr = d.getExclusions().iterator();
-                    while ( exclItr.hasNext() )
-                    {
-                        Exclusion e = (Exclusion) exclItr.next();
-                        exclusions.add( e.getGroupId() + ":" + e.getArtifactId() );
-                    }
-                    ExcludesArtifactFilter eaf = new ExcludesArtifactFilter( exclusions );
-                    artifact.setDependencyFilter( eaf );
-                }
-                else
-                {
-                    artifact.setDependencyFilter( null );
-                }
-                map.put( d.getManagementKey(), artifact );
-            }
+        ArtifactResolutionResult result;
+        try
+        {
+            result =
+                resolver.resolveTransitively( dependencyArtifacts, project.getArtifact(),
+                                              project.getManagedVersionMap(), localRepository, repos, metadataSource,
+                                              filter );
         }
-        else if ( map == null )
+        catch ( final ArtifactResolutionException e )
         {
-            map = Collections.EMPTY_MAP;
+            throw new DependencyResolutionException( "Failed to resolve dependencies for assembly: ", e );
         }
-        return map;
+        catch ( final ArtifactNotFoundException e )
+        {
+            throw new DependencyResolutionException( "Failed to resolve dependencies for assembly: ", e );
+        }
+
+        getLogger().debug( "While resolving dependencies of " + project.getId() + ":" );
+
+        FilterUtils.reportFilteringStatistics( Collections.singleton( filter ), getLogger() );
+
+        return result.getArtifacts();
     }
 
-    protected void getRepositoryResolutionRequirements( List repositories, ResolutionManagementInfo requirements )
+    protected void getRepositoryResolutionRequirements( final Assembly assembly,
+                                                        final ResolutionManagementInfo requirements,
+                                                        final MavenProject... project )
     {
+        final List<Repository> repositories = assembly.getRepositories();
+
         if ( repositories != null && !repositories.isEmpty() )
         {
             requirements.setResolutionRequired( true );
-            for ( Iterator it = repositories.iterator(); it.hasNext(); )
+            for ( final Repository repo : repositories )
             {
-                Repository repo = (Repository) it.next();
                 enableScope( repo.getScope(), requirements );
             }
         }
     }
 
-    protected void getModuleSetResolutionRequirements( List moduleSets, ResolutionManagementInfo requirements,
-                                                     AssemblerConfigurationSource configSource )
-        throws ArchiveCreationException
+    protected void getModuleSetResolutionRequirements( final Assembly assembly,
+                                                       final ResolutionManagementInfo requirements,
+                                                       final AssemblerConfigurationSource configSource )
+        throws DependencyResolutionException
     {
+        final List<ModuleSet> moduleSets = assembly.getModuleSets();
+
         if ( moduleSets != null && !moduleSets.isEmpty() )
         {
-            for ( Iterator it = moduleSets.iterator(); it.hasNext(); )
+            for ( final ModuleSet set : moduleSets )
             {
-                ModuleSet set = (ModuleSet) it.next();
-                
-                ModuleBinaries binaries = set.getBinaries();
+                final ModuleBinaries binaries = set.getBinaries();
                 if ( binaries != null )
                 {
-                    Set projects = ModuleSetAssemblyPhase.getModuleProjects( set, configSource, getLogger() );
+                    Set<MavenProject> projects;
+                    try
+                    {
+                        projects = ModuleSetAssemblyPhase.getModuleProjects( set, configSource, getLogger() );
+                    }
+                    catch ( final ArchiveCreationException e )
+                    {
+                        throw new DependencyResolutionException(
+                                                                 "Error determining project-set for moduleSet with binaries.",
+                                                                 e );
+                    }
+
                     if ( projects != null && !projects.isEmpty() )
                     {
-                        for ( Iterator projectIterator = projects.iterator(); projectIterator.hasNext(); )
+                        for ( final MavenProject p : projects )
                         {
-                            MavenProject p = (MavenProject) projectIterator.next();
                             requirements.enableProjectResolution( p );
+
+                            if ( p.getArtifact() == null )
+                            {
+                                // TODO: such a call in MavenMetadataSource too - packaging not really the intention of
+                                // type
+                                final Artifact artifact =
+                                    factory.createBuildArtifact( p.getGroupId(), p.getArtifactId(), p.getVersion(),
+                                                                 p.getPackaging() );
+                                p.setArtifact( artifact );
+                            }
                         }
                     }
-                    
+
                     if ( binaries.isIncludeDependencies() )
                     {
-                        getDependencySetResolutionRequirements( ModuleSetAssemblyPhase.getDependencySets( binaries ), requirements );
+                        getDependencySetResolutionRequirements( assembly,
+                                                                ModuleSetAssemblyPhase.getDependencySets( binaries ),
+                                                                requirements, projects.toArray( new MavenProject[] {} ) );
                     }
                 }
             }
         }
     }
 
-    protected void getDependencySetResolutionRequirements( List depSets, ResolutionManagementInfo requirements )
+    @SuppressWarnings( "unchecked" )
+    protected void getDependencySetResolutionRequirements( final Assembly assembly, final List<DependencySet> depSets,
+                                                           final ResolutionManagementInfo requirements,
+                                                           final MavenProject... projects )
+        throws DependencyResolutionException
     {
         if ( depSets != null && !depSets.isEmpty() )
         {
             requirements.setResolutionRequired( true );
-            for ( Iterator it = depSets.iterator(); it.hasNext(); )
+
+            for ( final DependencySet set : depSets )
             {
-                DependencySet set = (DependencySet) it.next();
-                
-                requirements.setResolvedTransitively( requirements.isResolvedTransitively() || set.isUseTransitiveDependencies() );
+                requirements.setResolvedTransitively( set.isUseTransitiveDependencies() );
+
                 enableScope( set.getScope(), requirements );
             }
+
+            for ( final MavenProject project : projects )
+            {
+                if ( project == null )
+                {
+                    continue;
+                }
+
+                Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
+                if ( dependencyArtifacts == null )
+                {
+                    try
+                    {
+                        dependencyArtifacts = project.createArtifacts( factory, null, requirements.getScopeFilter() );
+                        project.setDependencyArtifacts( dependencyArtifacts );
+                    }
+                    catch ( final InvalidDependencyVersionException e )
+                    {
+                        throw new DependencyResolutionException(
+                                                                 "Failed to create dependency artifacts for resolution. Assembly: "
+                                                                                 + assembly.getId(), e );
+                    }
+                }
+
+                requirements.addArtifacts( dependencyArtifacts );
+                getLogger().debug( "Dependencies for project: " + project.getId() + " are:\n"
+                                                   + StringUtils.join( dependencyArtifacts.iterator(), "\n" ) );
+            }
         }
     }
 
-    private void enableScope( String scope, ResolutionManagementInfo requirements )
+    private void enableScope( final String scope, final ResolutionManagementInfo requirements )
     {
         if ( Artifact.SCOPE_COMPILE.equals( scope ) )
         {
@@ -517,15 +359,52 @@ public class DefaultDependencyResolver
         }
     }
 
+    @SuppressWarnings( "unchecked" )
+    protected List<ArtifactRepository> aggregateRemoteArtifactRepositories( final List<ArtifactRepository> remoteRepositories,
+                                                                            final Set<MavenProject> projects )
+    {
+        final List<List<ArtifactRepository>> repoLists = new ArrayList<List<ArtifactRepository>>();
+
+        repoLists.add( remoteRepositories );
+        for ( final MavenProject project : projects )
+        {
+            repoLists.add( project.getRemoteArtifactRepositories() );
+        }
+
+        final List<ArtifactRepository> remoteRepos = new ArrayList<ArtifactRepository>();
+        final Set<String> encounteredUrls = new HashSet<String>();
+
+        for ( final Iterator<List<ArtifactRepository>> listIterator = repoLists.iterator(); listIterator.hasNext(); )
+        {
+            final List<ArtifactRepository> repositoryList = listIterator.next();
+
+            if ( ( repositoryList != null ) && !repositoryList.isEmpty() )
+            {
+                for ( final Iterator<ArtifactRepository> it = repositoryList.iterator(); it.hasNext(); )
+                {
+                    final ArtifactRepository repo = it.next();
+
+                    if ( !encounteredUrls.contains( repo.getUrl() ) )
+                    {
+                        remoteRepos.add( repo );
+                        encounteredUrls.add( repo.getUrl() );
+                    }
+                }
+            }
+        }
+
+        return remoteRepos;
+    }
+
     protected ArtifactResolver getArtifactResolver()
     {
         return resolver;
     }
 
-    protected DefaultDependencyResolver setArtifactResolver( ArtifactResolver resolver )
+    protected DefaultDependencyResolver setArtifactResolver( final ArtifactResolver resolver )
     {
         this.resolver = resolver;
-        
+
         return this;
     }
 
@@ -534,10 +413,10 @@ public class DefaultDependencyResolver
         return metadataSource;
     }
 
-    protected DefaultDependencyResolver setArtifactMetadataSource( ArtifactMetadataSource metadataSource )
+    protected DefaultDependencyResolver setArtifactMetadataSource( final ArtifactMetadataSource metadataSource )
     {
         this.metadataSource = metadataSource;
-        
+
         return this;
     }
 
@@ -546,10 +425,10 @@ public class DefaultDependencyResolver
         return factory;
     }
 
-    protected DefaultDependencyResolver setArtifactFactory( ArtifactFactory factory )
+    protected DefaultDependencyResolver setArtifactFactory( final ArtifactFactory factory )
     {
         this.factory = factory;
-        
+
         return this;
     }
 
@@ -558,17 +437,17 @@ public class DefaultDependencyResolver
         return collector;
     }
 
-    protected DefaultDependencyResolver setArtifactCollector( ArtifactCollector collector )
+    protected DefaultDependencyResolver setArtifactCollector( final ArtifactCollector collector )
     {
         this.collector = collector;
-        
+
         return this;
     }
-    
-    protected DefaultDependencyResolver setLogger( Logger logger )
+
+    protected DefaultDependencyResolver setLogger( final Logger logger )
     {
         enableLogging( logger );
-        
+
         return this;
     }
 

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DependencyResolver.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DependencyResolver.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DependencyResolver.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DependencyResolver.java Tue Sep 21 20:34:50 2010
@@ -19,25 +19,16 @@ package org.apache.maven.plugin.assembly
  * under the License.
  */
 
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
-import org.apache.maven.plugin.assembly.archive.ArchiveCreationException;
+import org.apache.maven.plugin.assembly.AssemblyContext;
 import org.apache.maven.plugin.assembly.model.Assembly;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 
 /**
- * Convenience component that aids in the resolution of dependency artifacts,
- * according to various configurations such as transitivity flag and scope.
+ * Convenience component that aids in the resolution of dependency artifacts, according to various configurations such
+ * as transitivity flag and scope.
  * 
  * @version $Id$
  */
@@ -47,40 +38,28 @@ public interface DependencyResolver
     /**
      * Resolve the project dependencies, according to the supplied configuration.
      * 
-     * @param project The project whose dependencies should be resolved
-     * @param scope The dependency scope to resolve
-     * @param managedVersions The map of managed versions, which allows 
-     *                        dependency version conflict resolution to happen 
-     *                        once for the entire assembly process.
-     * @param localRepository The local repository which acts as a local cache 
-     *                        for remote artifact repositories
-     * @param remoteRepositories The list of remote {@link ArtifactRepository} 
-     *                           instances to use during resolution, in addition 
-     *                           to those defined in the supplied 
-     *                           {@link MavenProject} instance.
-     * @param resolveTransitively If true, resolve project dependencies 
-     *                            transitively; if false, only resolve the 
-     *                            project's direct dependencies.
+     * @param project
+     *            The project whose dependencies should be resolved
+     * @param scope
+     *            The dependency scope to resolve
+     * @param managedVersions
+     *            The map of managed versions, which allows dependency version conflict resolution to happen once for
+     *            the entire assembly process.
+     * @param localRepository
+     *            The local repository which acts as a local cache for remote artifact repositories
+     * @param remoteRepositories
+     *            The list of remote {@link ArtifactRepository} instances to use during resolution, in addition to those
+     *            defined in the supplied {@link MavenProject} instance.
+     * @param resolveTransitively
+     *            If true, resolve project dependencies transitively; if false, only resolve the project's direct
+     *            dependencies.
      * @return The set of resolved {@link Artifact} instances for the project
      */
-    Set resolveDependencies( MavenProject project, String scope, Map managedVersions, ArtifactRepository localRepository,
-                                             List remoteRepositories, boolean resolveTransitively )
-        throws InvalidDependencyVersionException, ArtifactResolutionException, ArtifactNotFoundException;
+    // Set<Artifact> resolveDependencies( MavenProject project, String scope, ArtifactRepository localRepository,
+    // List<ArtifactRepository> remoteRepositories, boolean resolveTransitively )
+    // throws InvalidDependencyVersionException, ArtifactResolutionException, ArtifactNotFoundException;
 
-    /**
-     * Traverse the assembly descriptor to determine which scopes, modules, etc.
-     * will require dependency resolution. Once we have a complete picture of
-     * what will be required in the way of resolution, feed all of this into the
-     * {@link ArtifactCollector} to discover/resolve versions for all 
-     * dependencies in the mix, then save these versions in a mapping of:
-     * <br/>
-     * {@link Artifact#getDependencyConflictId()} -&gt; {@link Artifact}
-     * <br/>
-     * This allows dependency conflict resolution to happen a single time, then
-     * be reused multiple times during the construction of the assembly archive.
-     */
-    Map buildManagedVersionMap( Assembly assembly, AssemblerConfigurationSource configSource )
-        throws ArchiveCreationException, InvalidVersionSpecificationException, InvalidDependencyVersionException,
-        ArtifactResolutionException;
+    void resolve( Assembly assembly, AssemblerConfigurationSource configSource, AssemblyContext context )
+        throws DependencyResolutionException;
 
 }
\ No newline at end of file

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/ResolutionManagementInfo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/ResolutionManagementInfo.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/ResolutionManagementInfo.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/ResolutionManagementInfo.java Tue Sep 21 20:34:50 2010
@@ -1,31 +1,33 @@
 package org.apache.maven.plugin.assembly.artifact;
 
-import java.util.LinkedHashSet;
-import java.util.Set;
-
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.artifact.filter.ScopeArtifactFilter;
 
+import java.util.LinkedHashSet;
+import java.util.Set;
+
 /**
- * Helper class used to accumulate scopes and modules (with binaries included) 
- * that are used in an assembly, for the purposes of creating an aggregated
- * managed-version map with dependency version conflicts resolved.
+ * Helper class used to accumulate scopes and modules (with binaries included) that are used in an assembly, for the
+ * purposes of creating an aggregated managed-version map with dependency version conflicts resolved.
  * 
  * @author jdcasey
  */
 class ResolutionManagementInfo
 {
     private boolean resolutionRequired;
-    
-    private ScopeArtifactFilter scopeFilter = new ScopeArtifactFilter();
-    
+
+    private final ScopeArtifactFilter scopeFilter = new ScopeArtifactFilter();
+
     private boolean resolvedTransitively;
-    
-    private Set enabledProjects = new LinkedHashSet();
-    
-    ResolutionManagementInfo( MavenProject mainProject )
+
+    private final Set<MavenProject> enabledProjects = new LinkedHashSet<MavenProject>();
+
+    private final Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
+
+    ResolutionManagementInfo( final MavenProject currentProject )
     {
-        enabledProjects.add( mainProject );
+        enabledProjects.add( currentProject );
     }
 
     boolean isResolutionRequired()
@@ -33,7 +35,7 @@ class ResolutionManagementInfo
         return resolutionRequired;
     }
 
-    void setResolutionRequired( boolean resolutionRequired )
+    void setResolutionRequired( final boolean resolutionRequired )
     {
         this.resolutionRequired = resolutionRequired;
     }
@@ -43,16 +45,16 @@ class ResolutionManagementInfo
         return resolvedTransitively;
     }
 
-    void setResolvedTransitively( boolean resolvedTransitively )
+    void setResolvedTransitively( final boolean resolvedTransitively )
     {
-        this.resolvedTransitively = resolvedTransitively;
+        this.resolvedTransitively = this.resolvedTransitively || resolvedTransitively;
     }
 
     ScopeArtifactFilter getScopeFilter()
     {
         return scopeFilter;
     }
-    
+
     void enableCompileScope()
     {
         scopeFilter.setIncludeCompileScope( true );
@@ -84,8 +86,8 @@ class ResolutionManagementInfo
     {
         scopeFilter.setIncludeSystemScope( true );
     }
-    
-    void enableProjectResolution( MavenProject project )
+
+    void enableProjectResolution( final MavenProject project )
     {
         if ( !enabledProjects.contains( project ) )
         {
@@ -93,8 +95,23 @@ class ResolutionManagementInfo
         }
     }
 
-    Set getEnabledProjects()
+    Set<MavenProject> getEnabledProjects()
     {
         return enabledProjects;
     }
+
+    Set<Artifact> getArtifacts()
+    {
+        return artifacts;
+    }
+
+    void addArtifacts( final Set<Artifact> a )
+    {
+        artifacts.addAll( a );
+    }
+
+    void addArtifact( final Artifact a )
+    {
+        artifacts.add( a );
+    }
 }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AbstractLineAggregatingHandler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AbstractLineAggregatingHandler.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AbstractLineAggregatingHandler.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/AbstractLineAggregatingHandler.java Tue Sep 21 20:34:50 2010
@@ -20,18 +20,18 @@ package org.apache.maven.plugin.assembly
 import org.apache.maven.plugin.assembly.utils.AssemblyFileUtils;
 import org.codehaus.plexus.archiver.Archiver;
 import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.ResourceIterator;
 import org.codehaus.plexus.archiver.UnArchiver;
 import org.codehaus.plexus.components.io.fileselectors.FileInfo;
 import org.codehaus.plexus.util.IOUtil;
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.Writer;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -41,30 +41,55 @@ public abstract class AbstractLineAggreg
     implements ContainerDescriptorHandler
 {
 
-    private Map<String, StringWriter> catalog = new HashMap<String, StringWriter>();
+    private Map<String, List<String>> catalog = new HashMap<String, List<String>>();
 
-    private Map<String, List<String>> files = new HashMap<String, List<String>>();
+    private boolean excludeOverride = false;
 
     protected abstract String getOutputPathPrefix( final FileInfo fileInfo );
 
     protected abstract boolean fileMatches( final FileInfo fileInfo );
 
-    public void finalizeArchiveCreation( final Archiver archiver ) throws ArchiverException
+    protected String getEncoding()
     {
-        for ( final Map.Entry<String, StringWriter> entry : catalog.entrySet() )
+        return "UTF-8";
+    }
+
+    public void finalizeArchiveCreation( final Archiver archiver )
+        throws ArchiverException
+    {
+        // this will prompt the isSelected() call, below, for all resources added to the archive.
+        // FIXME: This needs to be corrected in the AbstractArchiver, where
+        // runArchiveFinalizers() is called before regular resources are added...
+        // which is done because the manifest needs to be added first, and the
+        // manifest-creation component is a finalizer in the assembly plugin...
+        for ( final ResourceIterator it = archiver.getResources(); it.hasNext(); )
+        {
+            it.next();
+        }
+
+        addToArchive( archiver );
+    }
+
+    protected void addToArchive( final Archiver archiver )
+        throws ArchiverException
+    {
+        for ( final Map.Entry<String, List<String>> entry : catalog.entrySet() )
         {
             final String name = entry.getKey();
             final String fname = new File( name ).getName();
 
-            Writer writer = null;
+            PrintWriter writer = null;
             File f;
             try
             {
                 f = File.createTempFile( "assembly-" + fname, ".tmp" );
                 f.deleteOnExit();
 
-                writer = new FileWriter( f );
-                writer.write( entry.getValue().toString() );
+                writer = new PrintWriter( new OutputStreamWriter( new FileOutputStream( f ), getEncoding() ) );
+                for ( final String line : entry.getValue() )
+                {
+                    writer.println( line );
+                }
             }
             catch ( final IOException e )
             {
@@ -75,10 +100,15 @@ public abstract class AbstractLineAggreg
             {
                 IOUtil.close( writer );
             }
+
+            excludeOverride = true;
+            archiver.addFile( f, name );
+            excludeOverride = false;
         }
     }
 
-    public void finalizeArchiveExtraction( final UnArchiver unArchiver ) throws ArchiverException
+    public void finalizeArchiveExtraction( final UnArchiver unArchiver )
+        throws ArchiverException
     {
     }
 
@@ -87,33 +117,30 @@ public abstract class AbstractLineAggreg
         return new ArrayList<String>( catalog.keySet() );
     }
 
-    public boolean isSelected( final FileInfo fileInfo ) throws IOException
+    public boolean isSelected( final FileInfo fileInfo )
+        throws IOException
     {
+        if ( excludeOverride )
+        {
+            return true;
+        }
+
         String name = fileInfo.getName();
         name = AssemblyFileUtils.normalizePath( name );
         name = name.replace( File.separatorChar, '/' );
 
-        name = getOutputPathPrefix( fileInfo ) + new File( name ).getName();
-
         if ( fileInfo.isFile() && fileMatches( fileInfo ) )
         {
-            StringWriter writer = catalog.get( name );
-            if ( writer == null )
-            {
-                writer = new StringWriter();
-                catalog.put( name, writer );
-            }
-
-            readLines( fileInfo, new PrintWriter( writer ) );
+            name = getOutputPathPrefix( fileInfo ) + new File( name ).getName();
 
-            List<String> aggregated = files.get( name );
-            if ( aggregated == null )
+            List<String> lines = catalog.get( name );
+            if ( lines == null )
             {
-                aggregated = new ArrayList<String>();
-                files.put( name, aggregated );
+                lines = new ArrayList<String>();
+                catalog.put( name, lines );
             }
 
-            aggregated.add( fileInfo.getName() );
+            readLines( fileInfo, lines );
 
             return false;
         }
@@ -121,16 +148,21 @@ public abstract class AbstractLineAggreg
         return true;
     }
 
-    protected void readLines( final FileInfo fileInfo, final PrintWriter writer ) throws IOException
+    protected void readLines( final FileInfo fileInfo, final List<String> lines )
+        throws IOException
     {
         BufferedReader reader = null;
         try
         {
-            reader = new BufferedReader( new InputStreamReader( fileInfo.getContents() ) ); // platform encoding
+            reader = new BufferedReader( new InputStreamReader( fileInfo.getContents(), getEncoding() ) );
+
             String line = null;
             while ( ( line = reader.readLine() ) != null )
             {
-                writer.println( line );
+                if ( !lines.contains( line ) )
+                {
+                    lines.add( line );
+                }
             }
         }
         finally
@@ -139,24 +171,14 @@ public abstract class AbstractLineAggreg
         }
     }
 
-    protected final Map<String, StringWriter> getCatalog()
+    protected final Map<String, List<String>> getCatalog()
     {
         return catalog;
     }
 
-    protected final Map<String, List<String>> getFiles()
-    {
-        return files;
-    }
-
-    protected final void setCatalog( final Map<String, StringWriter> catalog )
+    protected final void setCatalog( final Map<String, List<String>> catalog )
     {
         this.catalog = catalog;
     }
 
-    protected final void setFiles( final Map<String, List<String>> files )
-    {
-        this.files = files;
-    }
-
 }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/ComponentsXmlArchiverFileFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/ComponentsXmlArchiverFileFilter.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/ComponentsXmlArchiverFileFilter.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/ComponentsXmlArchiverFileFilter.java Tue Sep 21 20:34:50 2010
@@ -46,23 +46,23 @@ import java.util.Map;
 
 /**
  * Components XML file filter.
- *
+ * 
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @version $Id$
  */
 public class ComponentsXmlArchiverFileFilter
     implements ContainerDescriptorHandler
 {
-    // [jdcasey] Switched visibility to protected to allow testing. Also, because this class isn't final, it should allow
+    // [jdcasey] Switched visibility to protected to allow testing. Also, because this class isn't final, it should
+    // allow
     // some minimal access to the components accumulated for extending classes.
-    protected Map components;
+    protected Map<String, Xpp3Dom> components;
 
     private boolean excludeOverride = false;
 
     public static final String COMPONENTS_XML_PATH = "META-INF/plexus/components.xml";
 
-    protected void addComponentsXml( Reader componentsReader )
-        throws XmlPullParserException, IOException
+    protected void addComponentsXml( final Reader componentsReader ) throws XmlPullParserException, IOException
     {
         Xpp3Dom newDom = Xpp3DomBuilder.build( componentsReader );
 
@@ -73,22 +73,23 @@ public class ComponentsXmlArchiverFileFi
 
         if ( newDom != null )
         {
-            Xpp3Dom[] children = newDom.getChildren();
+            final Xpp3Dom[] children = newDom.getChildren();
 
             for ( int i = 0; i < children.length; i++ )
             {
-                Xpp3Dom component = children[i];
+                final Xpp3Dom component = children[i];
 
                 if ( components == null )
                 {
-                    components = new LinkedHashMap();
+                    components = new LinkedHashMap<String, Xpp3Dom>();
                 }
 
-                String role = component.getChild( "role" ).getValue();
-                Xpp3Dom child = component.getChild( "role-hint" );
-                String roleHint = child != null ? child.getValue() : "";
+                final String role = component.getChild( "role" )
+                                             .getValue();
+                final Xpp3Dom child = component.getChild( "role-hint" );
+                final String roleHint = child != null ? child.getValue() : "";
 
-                String key = role + roleHint;
+                final String key = role + roleHint;
                 if ( !components.containsKey( key ) )
                 {
                     System.out.println( "Adding " + key );
@@ -102,41 +103,41 @@ public class ComponentsXmlArchiverFileFi
         }
     }
 
-//    public void addComponentsXml( File componentsXml )
-//        throws IOException, XmlPullParserException
-//    {
-//        FileReader fileReader = null;
-//        try
-//        {
-//            fileReader = new FileReader( componentsXml );
-//
-//            addComponentsXml( fileReader );
-//        }
-//        finally
-//        {
-//            IOUtil.close( fileReader );
-//        }
-//    }
+    // public void addComponentsXml( File componentsXml )
+    // throws IOException, XmlPullParserException
+    // {
+    // FileReader fileReader = null;
+    // try
+    // {
+    // fileReader = new FileReader( componentsXml );
+    //
+    // addComponentsXml( fileReader );
+    // }
+    // finally
+    // {
+    // IOUtil.close( fileReader );
+    // }
+    // }
 
-    private void addToArchive( Archiver archiver )
-        throws IOException, ArchiverException
+    private void addToArchive( final Archiver archiver ) throws IOException, ArchiverException
     {
         if ( components != null )
         {
-            File f = File.createTempFile( "maven-assembly-plugin", "tmp" );
+            final File f = File.createTempFile( "maven-assembly-plugin", "tmp" );
             f.deleteOnExit();
 
             // TODO use WriterFactory.newXmlWriter() when plexus-utils is upgraded to 1.4.5+
-            Writer fileWriter = new OutputStreamWriter( new FileOutputStream( f ), "UTF-8" );
+            final Writer fileWriter = new OutputStreamWriter( new FileOutputStream( f ), "UTF-8" );
             try
             {
-                Xpp3Dom dom = new Xpp3Dom( "component-set" );
-                Xpp3Dom componentDom = new Xpp3Dom( "components" );
+                final Xpp3Dom dom = new Xpp3Dom( "component-set" );
+                final Xpp3Dom componentDom = new Xpp3Dom( "components" );
                 dom.addChild( componentDom );
 
-                for ( Iterator i = components.values().iterator(); i.hasNext(); )
+                for ( final Iterator<Xpp3Dom> i = components.values()
+                                                            .iterator(); i.hasNext(); )
                 {
-                    Xpp3Dom component = (Xpp3Dom) i.next();
+                    final Xpp3Dom component = i.next();
                     componentDom.addChild( component );
                 }
 
@@ -155,15 +156,14 @@ public class ComponentsXmlArchiverFileFi
         }
     }
 
-    public void finalizeArchiveCreation( Archiver archiver )
-        throws ArchiverException
+    public void finalizeArchiveCreation( final Archiver archiver ) throws ArchiverException
     {
         // this will prompt the isSelected() call, below, for all resources added to the archive.
         // FIXME: This needs to be corrected in the AbstractArchiver, where
         // runArchiveFinalizers() is called before regular resources are added...
         // which is done because the manifest needs to be added first, and the
         // manifest-creation component is a finalizer in the assembly plugin...
-        for ( ResourceIterator it = archiver.getResources(); it.hasNext(); )
+        for ( final ResourceIterator it = archiver.getResources(); it.hasNext(); )
         {
             it.next();
         }
@@ -172,13 +172,13 @@ public class ComponentsXmlArchiverFileFi
         {
             addToArchive( archiver );
         }
-        catch ( IOException e )
+        catch ( final IOException e )
         {
             throw new ArchiverException( "Error finalizing component-set for archive. Reason: " + e.getMessage(), e );
         }
     }
 
-    public List getVirtualFiles()
+    public List<String> getVirtualFiles()
     {
         if ( ( components != null ) && !components.isEmpty() )
         {
@@ -188,8 +188,7 @@ public class ComponentsXmlArchiverFileFi
         return null;
     }
 
-    public boolean isSelected( FileInfo fileInfo )
-        throws IOException
+    public boolean isSelected( final FileInfo fileInfo ) throws IOException
     {
         if ( fileInfo.isFile() )
         {
@@ -198,7 +197,8 @@ public class ComponentsXmlArchiverFileFi
                 return true;
             }
 
-            String entry = fileInfo.getName().replace( '\\', '/' );
+            String entry = fileInfo.getName()
+                                   .replace( '\\', '/' );
 
             if ( entry.startsWith( "/" ) )
             {
@@ -217,9 +217,10 @@ public class ComponentsXmlArchiverFileFi
                     reader = new InputStreamReader( stream, "UTF-8" );
                     addComponentsXml( reader );
                 }
-                catch ( XmlPullParserException e )
+                catch ( final XmlPullParserException e )
                 {
-                    IOException error = new IOException( "Error finalizing component-set for archive. Reason: " + e.getMessage() );
+                    final IOException error =
+                        new IOException( "Error finalizing component-set for archive. Reason: " + e.getMessage() );
                     error.initCause( e );
 
                     throw error;
@@ -243,8 +244,7 @@ public class ComponentsXmlArchiverFileFi
         }
     }
 
-    public void finalizeArchiveExtraction( UnArchiver unarchiver )
-        throws ArchiverException
+    public void finalizeArchiveExtraction( final UnArchiver unarchiver ) throws ArchiverException
     {
     }
 

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/MetaInfServicesHandler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/MetaInfServicesHandler.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/MetaInfServicesHandler.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/MetaInfServicesHandler.java Tue Sep 21 20:34:50 2010
@@ -25,7 +25,7 @@ public class MetaInfServicesHandler
     extends AbstractLineAggregatingHandler
 {
 
-    private static final String SERVICES_PATH_PREFIX = "/META-INF/services/";
+    private static final String SERVICES_PATH_PREFIX = "META-INF/services/";
 
     @Override
     protected String getOutputPathPrefix( final FileInfo fileInfo )
@@ -36,8 +36,19 @@ public class MetaInfServicesHandler
     @Override
     protected boolean fileMatches( final FileInfo fileInfo )
     {
-        return fileInfo.getName().startsWith( SERVICES_PATH_PREFIX )
-                        || fileInfo.getName().startsWith( "META-INF/services" );
+        final String path = fileInfo.getName();
+
+        String leftover = null;
+        if ( path.startsWith( SERVICES_PATH_PREFIX ) )
+        {
+            leftover = path.substring( SERVICES_PATH_PREFIX.length() );
+        }
+        else if ( path.startsWith( "/META-INF/services/" ) )
+        {
+            leftover = path.substring( SERVICES_PATH_PREFIX.length() - 1 );
+        }
+
+        return leftover != null && leftover.length() > 0;
     }
 
 }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/MetaInfSpringHandler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/MetaInfSpringHandler.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/MetaInfSpringHandler.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/MetaInfSpringHandler.java Tue Sep 21 20:34:50 2010
@@ -36,8 +36,19 @@ public class MetaInfSpringHandler
     @Override
     protected boolean fileMatches( final FileInfo fileInfo )
     {
-        return fileInfo.getName().startsWith( "/META-INF/spring." )
-                        || fileInfo.getName().startsWith( "META-INF/spring." );
+        final String path = fileInfo.getName();
+
+        String leftover = null;
+        if ( path.startsWith( "/META-INF/spring." ) )
+        {
+            leftover = path.substring( "/META-INF/spring.".length() );
+        }
+        else if ( path.startsWith( "META-INF/spring." ) )
+        {
+            leftover = path.substring( "META-INF/spring.".length() - 1 );
+        }
+
+        return leftover != null && leftover.length() > 0;
     }
 
 }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/SimpleAggregatingDescriptorHandler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/SimpleAggregatingDescriptorHandler.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/SimpleAggregatingDescriptorHandler.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/filter/SimpleAggregatingDescriptorHandler.java Tue Sep 21 20:34:50 2010
@@ -55,25 +55,24 @@ public class SimpleAggregatingDescriptor
 
     private String outputPath;
 
-    private String commentChars = "#";
+    private final String commentChars = "#";
 
     // calculated, temporary values.
 
     private boolean overrideFilterAction;
 
-    private StringWriter aggregateWriter = new StringWriter();
+    private final StringWriter aggregateWriter = new StringWriter();
 
-    private List filenames = new ArrayList();
+    private final List<String> filenames = new ArrayList<String>();
 
     // injected by the container.
 
     private Logger logger;
 
-    public void finalizeArchiveCreation( Archiver archiver )
-        throws ArchiverException
+    public void finalizeArchiveCreation( final Archiver archiver ) throws ArchiverException
     {
         checkConfig();
-        
+
         if ( outputPath.endsWith( "/" ) )
         {
             throw new ArchiverException(
@@ -86,7 +85,7 @@ public class SimpleAggregatingDescriptor
             outputPath = outputPath.substring( 1 );
         }
 
-        File temp = writePropertiesFile();
+        final File temp = writePropertiesFile();
 
         overrideFilterAction = true;
 
@@ -95,8 +94,7 @@ public class SimpleAggregatingDescriptor
         overrideFilterAction = false;
     }
 
-    private File writePropertiesFile()
-        throws ArchiverException
+    private File writePropertiesFile() throws ArchiverException
     {
         File f;
 
@@ -111,9 +109,9 @@ public class SimpleAggregatingDescriptor
 
             writer.write( commentChars + " Aggregated on " + new Date() + " from: " );
 
-            for ( Iterator it = filenames.iterator(); it.hasNext(); )
+            for ( final Iterator<String> it = filenames.iterator(); it.hasNext(); )
             {
-                String filename = (String) it.next();
+                final String filename = it.next();
 
                 writer.write( "\n" + commentChars + " " + filename );
             }
@@ -122,10 +120,10 @@ public class SimpleAggregatingDescriptor
 
             writer.write( aggregateWriter.toString() );
         }
-        catch ( IOException e )
+        catch ( final IOException e )
         {
             throw new ArchiverException( "Error adding aggregated properties to finalize archive creation. Reason: "
-                                         + e.getMessage(), e );
+                            + e.getMessage(), e );
         }
         finally
         {
@@ -135,23 +133,21 @@ public class SimpleAggregatingDescriptor
         return f;
     }
 
-    public void finalizeArchiveExtraction( UnArchiver unarchiver )
-        throws ArchiverException
+    public void finalizeArchiveExtraction( final UnArchiver unarchiver ) throws ArchiverException
     {
     }
 
-    public List getVirtualFiles()
+    public List<String> getVirtualFiles()
     {
         checkConfig();
-        
+
         return Collections.singletonList( outputPath );
     }
 
-    public boolean isSelected( FileInfo fileInfo )
-        throws IOException
+    public boolean isSelected( final FileInfo fileInfo ) throws IOException
     {
         checkConfig();
-        
+
         if ( overrideFilterAction )
         {
             System.out.println( "Filtering overridden. Returning true." );
@@ -178,14 +174,14 @@ public class SimpleAggregatingDescriptor
     {
         if ( filePattern == null || outputPath == null )
         {
-            throw new IllegalStateException( "You must configure filePattern and outputPath in your containerDescriptorHandler declaration." );
+            throw new IllegalStateException(
+                                             "You must configure filePattern and outputPath in your containerDescriptorHandler declaration." );
         }
     }
 
-    private void readProperties( FileInfo fileInfo )
-        throws IOException
+    private void readProperties( final FileInfo fileInfo ) throws IOException
     {
-        StringWriter writer = new StringWriter();
+        final StringWriter writer = new StringWriter();
         Reader reader = null;
         try
         {
@@ -199,7 +195,7 @@ public class SimpleAggregatingDescriptor
             IOUtil.close( reader );
         }
 
-        String content = writer.toString();
+        final String content = writer.toString();
 
         aggregateWriter.write( "\n" );
         aggregateWriter.write( content );
@@ -215,7 +211,7 @@ public class SimpleAggregatingDescriptor
         return logger;
     }
 
-    public void enableLogging( Logger logger )
+    public void enableLogging( final Logger logger )
     {
         this.logger = logger;
     }
@@ -225,7 +221,7 @@ public class SimpleAggregatingDescriptor
         return filePattern;
     }
 
-    public void setFilePattern( String filePattern )
+    public void setFilePattern( final String filePattern )
     {
         this.filePattern = filePattern;
     }
@@ -235,7 +231,7 @@ public class SimpleAggregatingDescriptor
         return outputPath;
     }
 
-    public void setOutputPath( String outputPath )
+    public void setOutputPath( final String outputPath )
     {
         this.outputPath = outputPath;
     }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/AssemblyFormattingException.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/AssemblyFormattingException.java?rev=999612&r1=999611&r2=999612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/AssemblyFormattingException.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/format/AssemblyFormattingException.java Tue Sep 21 20:34:50 2010
@@ -26,12 +26,14 @@ public class AssemblyFormattingException
     extends Exception
 {
 
-    public AssemblyFormattingException( String message, Throwable error )
+    private static final long serialVersionUID = 1L;
+
+    public AssemblyFormattingException( final String message, final Throwable error )
     {
         super( message, error );
     }
 
-    public AssemblyFormattingException( String message )
+    public AssemblyFormattingException( final String message )
     {
         super( message );
     }