Author: jdcasey
Date: Thu Nov 17 08:46:16 2005
New Revision: 345281

URL: http://svn.apache.org/viewcvs?rev=345281&view=rev
Log:
PR: MNG-1466
Submitted By: Garrett Conaty
Reviewed By: John Casey

Applied patch, with small changes to the default repository id's to match those 
in Maven proper. "default-local" -> "local", and "default-remote" -> "central".

This patch adds ID handling to repositories in the maven ant tasks. It should 
enable definition of multiple remote repositories in an Ant script.

Thanks, Garrett and Konstantin, for the work!

Modified:
    
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
    
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java
    
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java

Modified: 
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java?rev=345281&r1=345280&r2=345281&view=diff
==============================================================================
--- 
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
 (original)
+++ 
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
 Thu Nov 17 08:46:16 2005
@@ -91,7 +91,7 @@
         Authentication authentication = repository.getAuthentication();
         if ( authentication != null )
         {
-            manager.addAuthenticationInfo( "remote", 
authentication.getUserName(), authentication.getPassword(),
+            manager.addAuthenticationInfo( repository.getId(), 
authentication.getUserName(), authentication.getPassword(),
                                            authentication.getPrivateKey(), 
authentication.getPassphrase() );
         }
 
@@ -113,7 +113,7 @@
             ArtifactRepositoryPolicy snapshots = 
buildArtifactRepositoryPolicy( repository.getSnapshots() );
             ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( 
repository.getReleases() );
 
-            artifactRepository = repositoryFactory.createArtifactRepository( 
"remote", repository.getUrl(),
+            artifactRepository = repositoryFactory.createArtifactRepository( 
repository.getId(), repository.getUrl(),
                                                                              
repositoryLayout, snapshots, releases );
         }
         finally
@@ -157,6 +157,7 @@
     {
         Settings settings = getSettings();
         LocalRepository localRepository = new LocalRepository();
+        localRepository.setId( "local" );
         localRepository.setLocation( new File( settings.getLocalRepository() ) 
);
         return localRepository;
     }
@@ -232,6 +233,7 @@
         // As is, this could potentially cause a problem with 2 remote 
repositories with different authentication info
 
         RemoteRepository r = new RemoteRepository();
+        r.setId( pomRepository.getId() );
         r.setUrl( pomRepository.getUrl() );
         r.setLayout( pomRepository.getLayout() );
 
@@ -283,6 +285,7 @@
     {
         // TODO: could we utilise the super POM for this?
         RemoteRepository remoteRepository = new RemoteRepository();
+        remoteRepository.setId( "central" );
         remoteRepository.setUrl( "http://repo1.maven.org/maven2"; );
         RepositoryPolicy snapshots = new RepositoryPolicy();
         snapshots.setEnabled( false );

Modified: 
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java?rev=345281&r1=345280&r2=345281&view=diff
==============================================================================
--- 
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java
 (original)
+++ 
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java
 Thu Nov 17 08:46:16 2005
@@ -62,12 +62,12 @@
 
     public Proxy getProxy()
     {
-        return proxy;
+        return ( (RemoteRepository) getInstance() ).proxy;
     }
 
     public RepositoryPolicy getSnapshots()
     {
-        return snapshots;
+        return ( (RemoteRepository) getInstance() ).snapshots;
     }
 
     public void addSnapshots( RepositoryPolicy snapshots )
@@ -77,7 +77,7 @@
 
     public RepositoryPolicy getReleases()
     {
-        return releases;
+        return ( (RemoteRepository) getInstance() ).releases;
     }
 
     public void addReleases( RepositoryPolicy releases )

Modified: 
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java?rev=345281&r1=345280&r2=345281&view=diff
==============================================================================
--- 
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java
 (original)
+++ 
maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java
 Thu Nov 17 08:46:16 2005
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.ProjectComponent;
 
 /**
@@ -27,10 +28,27 @@
 public abstract class Repository
     extends ProjectComponent
 {
+       private String id;
+       
     private String refid;
 
     private String layout = "default";
 
+    public String getId()
+    {
+           System.out.println("Repository.getId() == " + getInstance().id);
+           if (getInstance().id == null)
+           {
+                   throw new BuildException("id must be specified for a 
repository definition");
+           }
+           return getInstance().id;
+    }
+    
+    public void setId( String id )
+    {
+           this.id = id;
+    }
+    
     public String getRefid()
     {
         return refid;


Reply via email to