diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java index 59eb4c3f48..fbdbdd888e 100755 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java +++ b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java @@ -91,7 +91,7 @@ public abstract class AbstractArtifactTask 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 @@ public abstract class AbstractArtifactTask 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 @@ public abstract class AbstractArtifactTask { Settings settings = getSettings(); LocalRepository localRepository = new LocalRepository(); + localRepository.setId( "local" ); localRepository.setLocation( new File( settings.getLocalRepository() ) ); return localRepository; } @@ -232,6 +233,7 @@ public abstract class AbstractArtifactTask // 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 @@ public abstract class AbstractArtifactTask { // 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 ); diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java index db3974cd1e..3ab77f6dbd 100755 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java +++ b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/RemoteRepository.java @@ -62,12 +62,12 @@ public class RemoteRepository 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 class RemoteRepository public RepositoryPolicy getReleases() { - return releases; + return ( (RemoteRepository) getInstance() ).releases; } public void addReleases( RepositoryPolicy releases ) diff --git a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java index 177ef0fe70..2de3b4864a 100755 --- a/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java +++ b/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Repository.java @@ -16,6 +16,7 @@ package org.apache.maven.artifact.ant; * limitations under the License. */ +import org.apache.tools.ant.BuildException; import org.apache.tools.ant.ProjectComponent; /** @@ -27,10 +28,27 @@ import org.apache.tools.ant.ProjectComponent; 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;