Maven Archiver 3.0.0 branch.

git-svn-id: https://svn.apache.org/repos/asf/maven/shared/branches/maven-archiver-3.0.0@1705906 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 84babf5..0bd3a07 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,9 @@
   </distributionManagement>
 
   <properties>
-    <mavenVersion>2.2.1</mavenVersion>
+    <mavenVersion>3.0</mavenVersion>
+    <maven.compiler.target>1.6</maven.compiler.target>
+    <maven.compiler.source>1.6</maven.compiler.source>
   </properties>
 
   <dependencies>
@@ -70,37 +72,25 @@
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-project</artifactId>
-      <version>${mavenVersion}</version>
-      <scope>provided</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>org.apache.maven</groupId>
-          <artifactId>maven-artifact-manager</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
       <version>${mavenVersion}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-shared-utils</artifactId>
-      <version>0.7</version>
+      <version>0.9</version>
     </dependency>
 
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-archiver</artifactId>
-      <version>2.9</version>
+      <version>3.0.1</version>
     </dependency>
     <!-- plexus-archiver needs this, or else maven-artifact will pull in a version from the pliocene era -->
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>3.0.20</version>
+      <version>3.0.22</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
diff --git a/src/main/java/org/apache/maven/archiver/MavenArchiver.java b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
index f577653..b03b52c 100644
--- a/src/main/java/org/apache/maven/archiver/MavenArchiver.java
+++ b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
@@ -63,9 +63,9 @@
     /**
      * Repository layout.
      */
-    public static final String REPOSITORY_LAYOUT = "${artifact.groupIdPath}/${artifact.artifactId}/"
-        + "${artifact.baseVersion}/${artifact.artifactId}-"
-        + "${artifact.version}${dashClassifier?}.${artifact.extension}";
+    public static final String REPOSITORY_LAYOUT =
+        "${artifact.groupIdPath}/${artifact.artifactId}/" + "${artifact.baseVersion}/${artifact.artifactId}-"
+            + "${artifact.version}${dashClassifier?}.${artifact.extension}";
 
     /**
      * simple layout non unique.
@@ -76,9 +76,9 @@
     /**
      * Repository layout non unique.
      */
-    public static final String REPOSITORY_LAYOUT_NONUNIQUE = "${artifact.groupIdPath}/${artifact.artifactId}/"
-        + "${artifact.baseVersion}/${artifact.artifactId}-"
-        + "${artifact.baseVersion}${dashClassifier?}.${artifact.extension}";
+    public static final String REPOSITORY_LAYOUT_NONUNIQUE =
+        "${artifact.groupIdPath}/${artifact.artifactId}/" + "${artifact.baseVersion}/${artifact.artifactId}-"
+            + "${artifact.baseVersion}${dashClassifier?}.${artifact.extension}";
 
     private static final List<String> ARTIFACT_EXPRESSION_PREFIXES;
 
@@ -243,12 +243,12 @@
      * @param config {@link ManifestConfiguration}
      * @param entries The entries.
      * @return {@link Manifest}
-     * @throws ManifestException The manifest exception. 
+     * @throws ManifestException The manifest exception.
      * @throws DependencyResolutionRequiredException The dependency resolution required exception.
      */
     protected Manifest getManifest( MavenSession session, MavenProject project, ManifestConfiguration config,
                                     Map<String, String> entries )
-        throws ManifestException, DependencyResolutionRequiredException
+                                        throws ManifestException, DependencyResolutionRequiredException
     {
         // TODO: Should we replace "map" with a copy? Note, that we modify it!
 
@@ -262,7 +262,6 @@
         {
             StringBuilder classpath = new StringBuilder();
 
-            @SuppressWarnings( "unchecked" )
             List<String> artifacts = project.getRuntimeClasspathElements();
             String classpathPrefix = config.getClasspathPrefix();
             String layoutType = config.getClasspathLayoutType();
@@ -275,7 +274,6 @@
                 File f = new File( artifactFile );
                 if ( f.getAbsoluteFile().isFile() )
                 {
-                    @SuppressWarnings( "unchecked" )
                     Artifact artifact = findArtifactWithFile( project.getArtifacts(), f );
 
                     if ( classpath.length() > 0 )
@@ -443,7 +441,6 @@
         {
             // TODO: this is only for applets - should we distinguish them as a packaging?
             StringBuilder extensionsList = new StringBuilder();
-            @SuppressWarnings( "unchecked" )
             Set<Artifact> artifacts = (Set<Artifact>) project.getArtifacts();
 
             for ( Artifact artifact : artifacts )
@@ -560,20 +557,13 @@
      */
     public void createArchive( MavenSession session, MavenProject project,
                                MavenArchiveConfiguration archiveConfiguration )
-        throws ArchiverException, ManifestException, IOException, DependencyResolutionRequiredException
+                                   throws ArchiverException, ManifestException, IOException,
+                                   DependencyResolutionRequiredException
     {
         // we have to clone the project instance so we can write out the pom with the deployment version,
         // without impacting the main project instance...
         MavenProject workingProject = null;
-        try
-        {
-            workingProject = (MavenProject) project.clone();
-        }
-        catch ( CloneNotSupportedException e )
-        {
-            // Should never happen
-            throw new ArchiverException( "Failed to clone Maven project", e );
-        }
+        workingProject = (MavenProject) project.clone();
 
         boolean forced = archiveConfiguration.isForced();
         if ( archiveConfiguration.isAddMavenDescriptor() )
@@ -640,7 +630,6 @@
         // make the archiver index the jars on the classpath, if we are adding that to the manifest
         if ( archiveConfiguration.getManifest().isAddClasspath() )
         {
-            @SuppressWarnings( "unchecked" )
             List<String> artifacts = project.getRuntimeClasspathElements();
             for ( String artifact : artifacts )
             {
@@ -667,7 +656,7 @@
         String createdBy = "Apache Maven";
         if ( session != null ) // can be null due to API backwards compatibility
         {
-            String mavenVersion = session.getExecutionProperties().getProperty( "maven.version" );
+            String mavenVersion = session.getUserProperties().getProperty( "maven.version" );
             if ( mavenVersion != null )
             {
                 createdBy += " " + mavenVersion;
diff --git a/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java b/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
index 939d64c..d4ba60d 100644
--- a/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
+++ b/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
@@ -1,5 +1,45 @@
 package org.apache.maven.archiver;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.DefaultMavenExecutionResult;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionResult;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Organization;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.io.FileUtils;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.jar.ManifestException;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -20,42 +60,6 @@
  */
 
 import junit.framework.TestCase;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.execution.ReactorManager;
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Organization;
-import org.apache.maven.monitor.event.EventDispatcher;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.settings.Settings;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.archiver.jar.JarArchiver;
-import org.codehaus.plexus.archiver.jar.ManifestException;
-import org.apache.maven.shared.utils.io.FileUtils;
-import org.apache.maven.shared.utils.StringUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
 
 public class MavenArchiverTest
     extends TestCase
@@ -865,11 +869,9 @@
         model.setVersion( "0.1" );
 
         final MavenProject project = new MavenProject( model );
-        project.setPluginArtifacts( Collections.EMPTY_SET );
-        project.setReportArtifacts( Collections.EMPTY_SET );
-        project.setExtensionArtifacts( Collections.EMPTY_SET );
-        project.setRemoteArtifactRepositories( Collections.EMPTY_LIST );
-        project.setPluginArtifactRepositories( Collections.EMPTY_LIST );
+        project.setExtensionArtifacts( Collections.<Artifact>emptySet() );
+        project.setRemoteArtifactRepositories( Collections.<ArtifactRepository>emptyList() );
+        project.setPluginArtifactRepositories( Collections.<ArtifactRepository>emptyList() );
         return project;
     }
 
@@ -1037,16 +1039,23 @@
     private MavenSession getDummySession( Properties executionProperties )
     {
         PlexusContainer container = null;
-        Settings settings = null;
-        ArtifactRepository localRepo = null;
-        EventDispatcher eventDispatcher = null;
-        ReactorManager reactorManager = null;
-        List<?> goals = null;
-        String executionRootDir = null;
+        File settings = null;
+        List<String> goals = null;
         Date startTime = new Date();
+        
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest();
+        request.setUserProperties( executionProperties );
+        request.setGoals( goals );
+        request.setStartTime( startTime );
+        request.setUserSettingsFile( settings );
+        
+        MavenExecutionResult result = new DefaultMavenExecutionResult();
+        
 
-        return new MavenSession( container, settings, localRepo, eventDispatcher, reactorManager, goals,
-                                 executionRootDir, executionProperties, startTime );
+        RepositorySystemSession rss = new DefaultRepositorySystemSession();
+        
+        return new MavenSession( container, rss, request, result );
+        
     }
 
     private Set<Artifact> getArtifacts( Artifact... artifacts )
diff --git a/src/test/java/org/apache/maven/archiver/MockArtifact.java b/src/test/java/org/apache/maven/archiver/MockArtifact.java
index 6dff386..07c46dd 100644
--- a/src/test/java/org/apache/maven/archiver/MockArtifact.java
+++ b/src/test/java/org/apache/maven/archiver/MockArtifact.java
@@ -1,5 +1,9 @@
 package org.apache.maven.archiver;
 
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -28,10 +32,6 @@
 import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
 import org.apache.maven.artifact.versioning.VersionRange;
 
-import java.io.File;
-import java.util.Collection;
-import java.util.List;
-
 /**
  * @todo move to maven-artifact-test
  */