mirror of https://github.com/apache/maven.git
MNG-5762 populate plugin repositories in ExecutionRequestPopulator
Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
parent
3c63c3b547
commit
d745f8c475
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue