mirror of
https://github.com/apache/maven.git
synced 2025-02-23 19:05:45 +00:00
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 @@ protected ArtifactRepository createRemoteArtifactRepository( RemoteRepository re
|
||||
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 @@ protected ArtifactRepository createRemoteArtifactRepository( RemoteRepository re
|
||||
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 @@ protected LocalRepository getDefaultLocalRepository()
|
||||
{
|
||||
Settings settings = getSettings();
|
||||
LocalRepository localRepository = new LocalRepository();
|
||||
localRepository.setId( "local" );
|
||||
localRepository.setLocation( new File( settings.getLocalRepository() ) );
|
||||
return localRepository;
|
||||
}
|
||||
@ -232,6 +233,7 @@ protected RemoteRepository createAntRemoteRepositoryBase( org.apache.maven.model
|
||||
// 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 @@ protected static RemoteRepository getDefaultRemoteRepository()
|
||||
{
|
||||
// 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 );
|
||||
|
@ -62,12 +62,12 @@ public void addProxy( Proxy proxy )
|
||||
|
||||
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 void addSnapshots( RepositoryPolicy snapshots )
|
||||
|
||||
public RepositoryPolicy getReleases()
|
||||
{
|
||||
return releases;
|
||||
return ( (RemoteRepository) getInstance() ).releases;
|
||||
}
|
||||
|
||||
public void addReleases( RepositoryPolicy releases )
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user