mirror of https://github.com/apache/maven.git
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! git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@345281 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e5320b624d
commit
df43187e32
|
@ -91,7 +91,7 @@ public abstract class AbstractArtifactTask
|
||||||
Authentication authentication = repository.getAuthentication();
|
Authentication authentication = repository.getAuthentication();
|
||||||
if ( authentication != null )
|
if ( authentication != null )
|
||||||
{
|
{
|
||||||
manager.addAuthenticationInfo( "remote", authentication.getUserName(), authentication.getPassword(),
|
manager.addAuthenticationInfo( repository.getId(), authentication.getUserName(), authentication.getPassword(),
|
||||||
authentication.getPrivateKey(), authentication.getPassphrase() );
|
authentication.getPrivateKey(), authentication.getPassphrase() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public abstract class AbstractArtifactTask
|
||||||
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repository.getSnapshots() );
|
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repository.getSnapshots() );
|
||||||
ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repository.getReleases() );
|
ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repository.getReleases() );
|
||||||
|
|
||||||
artifactRepository = repositoryFactory.createArtifactRepository( "remote", repository.getUrl(),
|
artifactRepository = repositoryFactory.createArtifactRepository( repository.getId(), repository.getUrl(),
|
||||||
repositoryLayout, snapshots, releases );
|
repositoryLayout, snapshots, releases );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -157,6 +157,7 @@ public abstract class AbstractArtifactTask
|
||||||
{
|
{
|
||||||
Settings settings = getSettings();
|
Settings settings = getSettings();
|
||||||
LocalRepository localRepository = new LocalRepository();
|
LocalRepository localRepository = new LocalRepository();
|
||||||
|
localRepository.setId( "local" );
|
||||||
localRepository.setLocation( new File( settings.getLocalRepository() ) );
|
localRepository.setLocation( new File( settings.getLocalRepository() ) );
|
||||||
return localRepository;
|
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
|
// As is, this could potentially cause a problem with 2 remote repositories with different authentication info
|
||||||
|
|
||||||
RemoteRepository r = new RemoteRepository();
|
RemoteRepository r = new RemoteRepository();
|
||||||
|
r.setId( pomRepository.getId() );
|
||||||
r.setUrl( pomRepository.getUrl() );
|
r.setUrl( pomRepository.getUrl() );
|
||||||
r.setLayout( pomRepository.getLayout() );
|
r.setLayout( pomRepository.getLayout() );
|
||||||
|
|
||||||
|
@ -283,6 +285,7 @@ public abstract class AbstractArtifactTask
|
||||||
{
|
{
|
||||||
// TODO: could we utilise the super POM for this?
|
// TODO: could we utilise the super POM for this?
|
||||||
RemoteRepository remoteRepository = new RemoteRepository();
|
RemoteRepository remoteRepository = new RemoteRepository();
|
||||||
|
remoteRepository.setId( "central" );
|
||||||
remoteRepository.setUrl( "http://repo1.maven.org/maven2" );
|
remoteRepository.setUrl( "http://repo1.maven.org/maven2" );
|
||||||
RepositoryPolicy snapshots = new RepositoryPolicy();
|
RepositoryPolicy snapshots = new RepositoryPolicy();
|
||||||
snapshots.setEnabled( false );
|
snapshots.setEnabled( false );
|
||||||
|
|
|
@ -62,12 +62,12 @@ public class RemoteRepository
|
||||||
|
|
||||||
public Proxy getProxy()
|
public Proxy getProxy()
|
||||||
{
|
{
|
||||||
return proxy;
|
return ( (RemoteRepository) getInstance() ).proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RepositoryPolicy getSnapshots()
|
public RepositoryPolicy getSnapshots()
|
||||||
{
|
{
|
||||||
return snapshots;
|
return ( (RemoteRepository) getInstance() ).snapshots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSnapshots( RepositoryPolicy snapshots )
|
public void addSnapshots( RepositoryPolicy snapshots )
|
||||||
|
@ -77,7 +77,7 @@ public class RemoteRepository
|
||||||
|
|
||||||
public RepositoryPolicy getReleases()
|
public RepositoryPolicy getReleases()
|
||||||
{
|
{
|
||||||
return releases;
|
return ( (RemoteRepository) getInstance() ).releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addReleases( RepositoryPolicy releases )
|
public void addReleases( RepositoryPolicy releases )
|
||||||
|
|
|
@ -16,6 +16,7 @@ package org.apache.maven.artifact.ant;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.ProjectComponent;
|
import org.apache.tools.ant.ProjectComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,10 +28,27 @@ import org.apache.tools.ant.ProjectComponent;
|
||||||
public abstract class Repository
|
public abstract class Repository
|
||||||
extends ProjectComponent
|
extends ProjectComponent
|
||||||
{
|
{
|
||||||
|
private String id;
|
||||||
|
|
||||||
private String refid;
|
private String refid;
|
||||||
|
|
||||||
private String layout = "default";
|
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()
|
public String getRefid()
|
||||||
{
|
{
|
||||||
return refid;
|
return refid;
|
||||||
|
|
Loading…
Reference in New Issue