From a48ae318c671c99048010183227d078d19dc972b Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Fri, 24 Jul 2009 14:23:45 +0000 Subject: [PATCH] o Refactored code git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@797479 13f79535-47bb-0310-9956-ffa450edef68 --- ...DefaultMavenExecutionRequestPopulator.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java index 725cd24827..050b0f4fcb 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java @@ -122,14 +122,7 @@ public class DefaultMavenExecutionRequestPopulator private void injectDefaultRepositories( MavenExecutionRequest request ) throws MavenEmbedderException { - Set definedRepositories = new HashSet(); - if ( request.getRemoteRepositories() != null ) - { - for ( ArtifactRepository repository : request.getRemoteRepositories() ) - { - definedRepositories.add( repository.getId() ); - } - } + Set definedRepositories = getRepoIds( request.getRemoteRepositories() ); if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) ) { @@ -147,14 +140,7 @@ public class DefaultMavenExecutionRequestPopulator private void injectDefaultPluginRepositories( MavenExecutionRequest request ) throws MavenEmbedderException { - Set definedRepositories = new HashSet(); - if ( request.getPluginArtifactRepositories() != null ) - { - for ( ArtifactRepository repository : request.getPluginArtifactRepositories() ) - { - definedRepositories.add( repository.getId() ); - } - } + Set definedRepositories = getRepoIds( request.getPluginArtifactRepositories() ); if ( !definedRepositories.contains( RepositorySystem.DEFAULT_REMOTE_REPO_ID ) ) { @@ -169,6 +155,21 @@ public class DefaultMavenExecutionRequestPopulator } } + private Set getRepoIds( List repositories ) + { + Set repoIds = new HashSet(); + + if ( repositories != null ) + { + for ( ArtifactRepository repository : repositories ) + { + repoIds.add( repository.getId() ); + } + } + + return repoIds; + } + private void processRepositoriesInSettings( MavenExecutionRequest request ) throws MavenEmbedderException {