Repository: maven Updated Branches: refs/heads/project-basedir b71b3ed93 -> 888109c68 (forced update)
MNG-5762 populate plugin repositories in ExecutionRequestPopulator Signed-off-by: Igor Fedorenko <ifedore...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/d745f8c4 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/d745f8c4 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/d745f8c4 Branch: refs/heads/project-basedir Commit: d745f8c47506bd93d4ae9eca830db50ad40ba61d Parents: 3c63c3b Author: Igor Fedorenko <ifedore...@apache.org> Authored: Wed Feb 4 22:11:30 2015 -0500 Committer: Igor Fedorenko <ifedore...@apache.org> Committed: Wed Feb 4 22:26:16 2015 -0500 ---------------------------------------------------------------------- .../DefaultMavenExecutionRequestPopulator.java | 29 +++++++-- ...faultMavenExecutionRequestPopulatorTest.java | 62 ++++++++++++++++++++ 2 files changed, 86 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/d745f8c4/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java index 4d79e14..bb794ee 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java @@ -27,6 +27,9 @@ import java.util.List; import java.util.Map; import java.util.Set; +import javax.inject.Inject; +import javax.inject.Named; + import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.bridge.MavenRepositorySystem; @@ -39,17 +42,20 @@ import org.apache.maven.settings.Settings; import org.apache.maven.settings.SettingsUtils; import org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.ToolchainModel; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; -@Component( role = MavenExecutionRequestPopulator.class ) +@Named public class DefaultMavenExecutionRequestPopulator implements MavenExecutionRequestPopulator { - @Requirement - private RepositorySystem repositorySystem; + private final RepositorySystem repositorySystem; + + @Inject + public DefaultMavenExecutionRequestPopulator( RepositorySystem repositorySystem ) + { + this.repositorySystem = repositorySystem; + } @Override public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings ) @@ -134,6 +140,19 @@ public class DefaultMavenExecutionRequestPopulator // do nothing for now } } + + List<Repository> pluginRepositories = rawProfile.getPluginRepositories(); + for ( Repository pluginRepository : pluginRepositories ) + { + try + { + request.addPluginArtifactRepository( MavenRepositorySystem.buildArtifactRepository( pluginRepository ) ); + } + catch ( InvalidRepositoryException e ) + { + // do nothing for now + } + } } } http://git-wip-us.apache.org/repos/asf/maven/blob/d745f8c4/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java ---------------------------------------------------------------------- diff --git a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java new file mode 100644 index 0000000..5019c7f --- /dev/null +++ b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulatorTest.java @@ -0,0 +1,62 @@ +package org.apache.maven.execution; + +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.repository.TestRepositorySystem; +import org.apache.maven.settings.Profile; +import org.apache.maven.settings.Repository; +import org.apache.maven.settings.Settings; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class DefaultMavenExecutionRequestPopulatorTest + extends TestCase +{ + DefaultMavenExecutionRequestPopulator testee = + new DefaultMavenExecutionRequestPopulator( new TestRepositorySystem() ); + + public void testPluginRepositoryInjection() + throws Exception + { + MavenExecutionRequest request = new DefaultMavenExecutionRequest(); + + Repository r = new Repository(); + r.setId( "test" ); + r.setUrl( "file:///test" ); + + Profile p = new Profile(); + p.setId( "test" ); + p.addPluginRepository( r ); + + Settings settings = new Settings(); + settings.addProfile( p ); + settings.addActiveProfile( p.getId() ); + + testee.populateFromSettings( request, settings ); + + List<ArtifactRepository> repositories = request.getPluginArtifactRepositories(); + assertEquals( 1, repositories.size() ); + assertEquals( r.getId(), repositories.get( 0 ).getId() ); + assertEquals( r.getUrl(), repositories.get( 0 ).getUrl() ); + } +}