mirror of https://github.com/apache/maven.git
o fixed mirror code
o more plugin manager wrangling git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@750568 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e1602d1a96
commit
b9f9244f5f
|
@ -38,12 +38,14 @@ public interface ArtifactRepository
|
|||
String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository );
|
||||
|
||||
String getUrl();
|
||||
void setUrl( String url );
|
||||
|
||||
String getBasedir();
|
||||
|
||||
String getProtocol();
|
||||
|
||||
String getId();
|
||||
void setId( String id );
|
||||
|
||||
ArtifactRepositoryPolicy getSnapshots();
|
||||
void setSnapshotUpdatePolicy( ArtifactRepositoryPolicy policy );
|
||||
|
|
|
@ -194,11 +194,7 @@ public class DefaultBuildPlanner
|
|||
final boolean allowUnbindableMojos )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding,
|
||||
plan,
|
||||
project,
|
||||
session,
|
||||
allowUnbindableMojos );
|
||||
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project, session, allowUnbindableMojos );
|
||||
|
||||
if ( pluginDescriptor == null )
|
||||
{
|
||||
|
@ -314,14 +310,11 @@ public class DefaultBuildPlanner
|
|||
}
|
||||
}
|
||||
|
||||
private PluginDescriptor loadPluginDescriptor( final MojoBinding mojoBinding,
|
||||
final BuildPlan plan,
|
||||
final MavenProject project,
|
||||
final MavenSession session,
|
||||
final boolean allowUnbindableMojos )
|
||||
private PluginDescriptor loadPluginDescriptor( final MojoBinding mojoBinding, final BuildPlan plan, final MavenProject project, final MavenSession session, final boolean allowUnbindableMojos )
|
||||
throws LifecyclePlannerException
|
||||
{
|
||||
PluginDescriptor pluginDescriptor = null;
|
||||
|
||||
try
|
||||
{
|
||||
pluginDescriptor = pluginLoader.loadPlugin( mojoBinding, project, session );
|
||||
|
@ -330,9 +323,7 @@ public class DefaultBuildPlanner
|
|||
{
|
||||
if ( allowUnbindableMojos )
|
||||
{
|
||||
String message = "Failed to load plugin: "
|
||||
+ MojoBindingUtils.createPluginKey( mojoBinding )
|
||||
+ ". Adding to late-bound plugins list.\nReason: " + e.getMessage();
|
||||
String message = "Failed to load plugin: " + MojoBindingUtils.createPluginKey( mojoBinding ) + ". Adding to late-bound plugins list.\nReason: " + e.getMessage();
|
||||
|
||||
if ( logger.isDebugEnabled() )
|
||||
{
|
||||
|
|
|
@ -64,7 +64,7 @@ public class DefaultPluginLoader
|
|||
*/
|
||||
public PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, MavenSession session )
|
||||
throws PluginLoaderException
|
||||
{
|
||||
{
|
||||
if ( plugin.getGroupId() == null )
|
||||
{
|
||||
plugin.setGroupId( PluginDescriptor.getDefaultPluginGroupId() );
|
||||
|
|
|
@ -83,12 +83,12 @@ public class DefaultPluginManagerSupport
|
|||
|
||||
MavenProject pluginProject = buildPluginProject( plugin, localRepository, project.getRemoteArtifactRepositories() );
|
||||
|
||||
Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() );
|
||||
|
||||
checkRequiredMavenVersion( plugin, pluginProject, localRepository, project.getRemoteArtifactRepositories() );
|
||||
|
||||
checkPluginDependencySpec( plugin, pluginProject );
|
||||
|
||||
Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() );
|
||||
|
||||
pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact );
|
||||
|
||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest( pluginArtifact, localRepository, project.getRemoteArtifactRepositories() );
|
||||
|
@ -100,13 +100,15 @@ public class DefaultPluginManagerSupport
|
|||
return pluginArtifact;
|
||||
}
|
||||
|
||||
public MavenProject buildPluginProject( Plugin plugin, ArtifactRepository localRepository, List remoteRepositories )
|
||||
public MavenProject buildPluginProject( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws InvalidPluginException
|
||||
{
|
||||
Artifact artifact = repositorySystem.createProjectArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() );
|
||||
try
|
||||
{
|
||||
return mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository );
|
||||
MavenProject p = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository );
|
||||
|
||||
return p;
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ public interface PluginManagerSupport
|
|||
Artifact resolvePluginArtifact( Plugin plugin, MavenProject project, MavenSession session )
|
||||
throws PluginManagerException, InvalidPluginException, PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException;
|
||||
|
||||
MavenProject buildPluginProject( Plugin plugin, ArtifactRepository localRepository, List remoteRepositories )
|
||||
MavenProject buildPluginProject( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws InvalidPluginException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -274,19 +274,20 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
|
||||
for ( Server server : settings.getServers() )
|
||||
{
|
||||
String pass;
|
||||
String phrase;
|
||||
String password;
|
||||
String passPhrase;
|
||||
|
||||
try
|
||||
{
|
||||
pass = securityDispatcher.decrypt( server.getPassword() );
|
||||
phrase = securityDispatcher.decrypt( server.getPassphrase() );
|
||||
password = securityDispatcher.decrypt( server.getPassword() );
|
||||
passPhrase = securityDispatcher.decrypt( server.getPassphrase() );
|
||||
}
|
||||
catch ( SecDispatcherException e )
|
||||
{
|
||||
throw new MavenEmbedderException( "Error decrypting server password/passphrase.", e );
|
||||
}
|
||||
|
||||
repositorySystem.addAuthenticationInfo( server.getId(), server.getUsername(), pass, server.getPrivateKey(), phrase );
|
||||
repositorySystem.addAuthenticationInfo( server.getId(), server.getUsername(), password, server.getPrivateKey(), passPhrase );
|
||||
|
||||
repositorySystem.addPermissionInfo( server.getId(), server.getFilePermissions(), server.getDirectoryPermissions() );
|
||||
}
|
||||
|
|
|
@ -217,21 +217,12 @@ public class DefaultMavenProjectBuilder
|
|||
{
|
||||
return project;
|
||||
}
|
||||
|
||||
List<ArtifactRepository> artifactRepositories = new ArrayList<ArtifactRepository>( remoteRepositories );
|
||||
try
|
||||
{
|
||||
artifactRepositories.addAll( repositorySystem.buildArtifactRepositories( getSuperModel().getRepositories() ) );
|
||||
}
|
||||
catch ( InvalidRepositoryException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Cannot create repositories from super model.", e.getMessage() );
|
||||
}
|
||||
|
||||
|
||||
File f = (artifact.getFile() != null) ? artifact.getFile() : new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
|
||||
try
|
||||
{
|
||||
repositorySystem.findModelFromRepository( artifact, artifactRepositories, localRepository );
|
||||
|
||||
try
|
||||
{
|
||||
repositorySystem.findModelFromRepository( artifact, remoteRepositories, localRepository );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
|
@ -250,7 +241,8 @@ public class DefaultMavenProjectBuilder
|
|||
.setLocalRepository( localRepository )
|
||||
.setRemoteRepositories( remoteRepositories );
|
||||
|
||||
project = readModelFromLocalPath( "unknown", artifact.getFile(), config.getLocalRepository(), artifactRepositories, config );
|
||||
project = readModelFromLocalPath( "unknown", artifact.getFile(), config.getLocalRepository(), remoteRepositories
|
||||
, config );
|
||||
project = buildWithProfiles( project.getModel(), config, artifact.getFile(), project.getParentFile() );
|
||||
artifact.setFile( f );
|
||||
project.setVersion( artifact.getVersion() );
|
||||
|
|
|
@ -91,36 +91,23 @@ public class DefaultMirrorBuilder
|
|||
|
||||
public List<ArtifactRepository> getMirrors( List<ArtifactRepository> remoteRepositories )
|
||||
{
|
||||
Set<ArtifactRepository> remoteRepositoriesWithMirrors = new LinkedHashSet<ArtifactRepository>();
|
||||
|
||||
if ( remoteRepositories != null )
|
||||
{
|
||||
for ( ArtifactRepository repository : remoteRepositories)
|
||||
{
|
||||
// Check to see if we have a valid mirror for this repository
|
||||
ArtifactRepository mirror = getMirror( repository );
|
||||
|
||||
if ( mirror != null )
|
||||
{
|
||||
// Make sure that we take the the properties of the repository we are mirroring we want to direct
|
||||
// all requests for this mirror at the mirror, but the mirror specification does not allow for
|
||||
// any of the regular settings.
|
||||
mirror.setLayout( repository.getLayout() );
|
||||
mirror.setSnapshotUpdatePolicy( repository.getSnapshots() );
|
||||
mirror.setReleaseUpdatePolicy( repository.getReleases() );
|
||||
|
||||
// If there is a valid mirror for this repository then we'll enter the mirror as a replacement for this repository.
|
||||
remoteRepositoriesWithMirrors.add( mirror );
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we have no valid mirrors for this repository we will keep this repository in the list.
|
||||
remoteRepositoriesWithMirrors.add( repository );
|
||||
if ( mirror != null )
|
||||
{
|
||||
// We basically just want to take the URL
|
||||
repository.setUrl( mirror.getUrl() );
|
||||
repository.setId( repository.getId() + "-" + mirror.getId() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ArrayList<ArtifactRepository>( remoteRepositoriesWithMirrors );
|
||||
return remoteRepositories;
|
||||
}
|
||||
|
||||
// Make these available to tests
|
||||
|
|
|
@ -448,19 +448,14 @@ public class LegacyMavenRepositorySystem
|
|||
|
||||
public void findModelFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
|
||||
throws InvalidRepositoryException, ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
|
||||
{
|
||||
if ( cache.containsKey( artifact.getId() ) )
|
||||
{
|
||||
artifact.setFile( cache.get( artifact.getId() ).getFile() );
|
||||
}
|
||||
|
||||
String projectId = safeVersionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
|
||||
remoteArtifactRepositories = normalizeToArtifactRepositories( remoteArtifactRepositories, projectId );
|
||||
|
||||
Artifact projectArtifact;
|
||||
|
||||
|
||||
// if the artifact is not a POM, we need to construct a POM artifact based on the artifact parameter given.
|
||||
/*
|
||||
if ( "pom".equals( artifact.getType() ) )
|
||||
{
|
||||
projectArtifact = artifact;
|
||||
|
@ -472,55 +467,15 @@ public class LegacyMavenRepositorySystem
|
|||
|
||||
projectArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope() );
|
||||
}
|
||||
|
||||
ArtifactResolutionRequest request =
|
||||
new ArtifactResolutionRequest( projectArtifact, localRepository, remoteArtifactRepositories );
|
||||
*/
|
||||
|
||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest( artifact, localRepository, remoteArtifactRepositories );
|
||||
ArtifactResolutionResult result = resolve( request );
|
||||
resolutionErrorHandler.throwErrors( request, result );
|
||||
|
||||
File file = projectArtifact.getFile();
|
||||
artifact.setFile( file );
|
||||
|
||||
cache.put( artifact.getId(), artifact );
|
||||
}
|
||||
|
||||
private List normalizeToArtifactRepositories( List remoteArtifactRepositories, String projectId )
|
||||
throws InvalidRepositoryException
|
||||
{
|
||||
List normalized = new ArrayList( remoteArtifactRepositories.size() );
|
||||
|
||||
boolean normalizationNeeded = false;
|
||||
for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); )
|
||||
{
|
||||
Object item = it.next();
|
||||
|
||||
if ( item instanceof ArtifactRepository )
|
||||
{
|
||||
normalized.add( item );
|
||||
}
|
||||
else if ( item instanceof Repository )
|
||||
{
|
||||
Repository repo = (Repository) item;
|
||||
item = buildArtifactRepository( repo );
|
||||
|
||||
normalized.add( item );
|
||||
normalizationNeeded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidRepositoryException( projectId, "Error building artifact repository from non-repository information item: " + item );
|
||||
}
|
||||
}
|
||||
|
||||
if ( normalizationNeeded )
|
||||
{
|
||||
return normalized;
|
||||
}
|
||||
else
|
||||
{
|
||||
return remoteArtifactRepositories;
|
||||
}
|
||||
}
|
||||
|
||||
private String safeVersionlessKey( String groupId, String artifactId )
|
||||
{
|
||||
String gid = groupId;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package org.apache.maven.repository;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
|
||||
|
|
Loading…
Reference in New Issue