mirror of https://github.com/apache/maven.git
o add default plugin artifact repositories in the populator
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@796817 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c6eb6bd219
commit
b69b4ab4f9
|
@ -837,6 +837,21 @@ public class DefaultMavenExecutionRequest
|
|||
return remoteRepositories;
|
||||
}
|
||||
|
||||
public MavenExecutionRequest addPluginArtifactRepository( ArtifactRepository repository )
|
||||
{
|
||||
for ( ArtifactRepository repo : getPluginArtifactRepositories() )
|
||||
{
|
||||
if ( repo.getId() != null && repo.getId().equals( repository.getId() ) )
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
getPluginArtifactRepositories().add( repository );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ArtifactRepository> getPluginArtifactRepositories()
|
||||
{
|
||||
if ( pluginArtifactRepositories == null )
|
||||
|
|
|
@ -207,6 +207,8 @@ public interface MavenExecutionRequest
|
|||
MavenExecutionRequest setGlobalSettingsFile( File globalSettingsFile );
|
||||
|
||||
MavenExecutionRequest addRemoteRepository( ArtifactRepository repository );
|
||||
MavenExecutionRequest addPluginArtifactRepository( ArtifactRepository repository );
|
||||
|
||||
/**
|
||||
* Set a new list of remote repositories to use the execution request. This is necessary if you perform
|
||||
* transformations on the remote repositories being used. For example if you replace existing repositories with
|
||||
|
|
|
@ -114,6 +114,8 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
|
||||
injectDefaultRepositories( request );
|
||||
|
||||
injectDefaultPluginRepositories( request );
|
||||
|
||||
processRepositoriesInSettings( request );
|
||||
}
|
||||
|
||||
|
@ -142,6 +144,31 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
}
|
||||
}
|
||||
|
||||
private void injectDefaultPluginRepositories( MavenExecutionRequest request )
|
||||
throws MavenEmbedderException
|
||||
{
|
||||
Set<String> definedRepositories = new HashSet<String>();
|
||||
if ( request.getPluginArtifactRepositories() != null )
|
||||
{
|
||||
for ( ArtifactRepository repository : request.getPluginArtifactRepositories() )
|
||||
{
|
||||
definedRepositories.add( repository.getId() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
request.addPluginArtifactRepository( repositorySystem.createDefaultRemoteRepository() );
|
||||
}
|
||||
catch ( InvalidRepositoryException e )
|
||||
{
|
||||
throw new MavenEmbedderException( "Cannot create default remote repository.", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processRepositoriesInSettings( MavenExecutionRequest request )
|
||||
throws MavenEmbedderException
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue