mirror of https://github.com/apache/maven.git
Removed use of workspace from project builder. In the build of trunk, there were about 50K of calls from MavenMetadataSource to the project builder. I put a simple hashmap cache in the metadata source to reduce calls to dozens.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@699773 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1260ced4f5
commit
53cfcc896d
|
@ -132,11 +132,7 @@ public class DefaultMavenProjectBuilder
|
||||||
public MavenProject build( File projectDescriptor, ProjectBuilderConfiguration config )
|
public MavenProject build( File projectDescriptor, ProjectBuilderConfiguration config )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
MavenProject project = projectWorkspace.getProject( projectDescriptor );
|
MavenProject project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver(
|
||||||
|
|
||||||
if ( project == null )
|
|
||||||
{
|
|
||||||
project = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver(
|
|
||||||
config.getLocalRepository(), repositoryHelper.buildArtifactRepositories(
|
config.getLocalRepository(), repositoryHelper.buildArtifactRepositories(
|
||||||
getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config );
|
getSuperProject( config, projectDescriptor, true ).getModel() ), artifactResolver ), config );
|
||||||
|
|
||||||
|
@ -152,8 +148,6 @@ public class DefaultMavenProjectBuilder
|
||||||
project.setFile( projectDescriptor );
|
project.setFile( projectDescriptor );
|
||||||
|
|
||||||
setBuildOutputDirectoryOnParent( project );
|
setBuildOutputDirectoryOnParent( project );
|
||||||
|
|
||||||
}
|
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,21 +164,11 @@ public class DefaultMavenProjectBuilder
|
||||||
return buildFromRepository( artifact, remoteArtifactRepositories, localRepository );
|
return buildFromRepository( artifact, remoteArtifactRepositories, localRepository );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
MavenProject project = null;
|
|
||||||
if ( !Artifact.LATEST_VERSION.equals( artifact.getVersion() ) &&
|
|
||||||
!Artifact.RELEASE_VERSION.equals( artifact.getVersion() ) )
|
|
||||||
{
|
|
||||||
project =
|
|
||||||
projectWorkspace.getProject( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
|
|
||||||
}
|
|
||||||
File f = artifact.getFile();
|
File f = artifact.getFile();
|
||||||
if ( project == null )
|
|
||||||
{
|
|
||||||
repositoryHelper.findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
|
repositoryHelper.findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
|
||||||
|
|
||||||
ProjectBuilderConfiguration config =
|
ProjectBuilderConfiguration config =
|
||||||
|
@ -195,10 +179,9 @@ public class DefaultMavenProjectBuilder
|
||||||
artifactRepositories.addAll( repositoryHelper.buildArtifactRepositories(
|
artifactRepositories.addAll( repositoryHelper.buildArtifactRepositories(
|
||||||
getSuperProject( config, artifact.getFile(), false ).getModel() ) );
|
getSuperProject( config, artifact.getFile(), false ).getModel() ) );
|
||||||
|
|
||||||
project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver(
|
MavenProject project = readModelFromLocalPath( "unknown", artifact.getFile(), new PomArtifactResolver(
|
||||||
config.getLocalRepository(), artifactRepositories, artifactResolver ), config );
|
config.getLocalRepository(), artifactRepositories, artifactResolver ), config );
|
||||||
project = buildInternal( project.getModel(), config, artifact.getFile(), project.getParentFile(), false );
|
project = buildInternal( project.getModel(), config, artifact.getFile(), project.getParentFile(), false );
|
||||||
}
|
|
||||||
|
|
||||||
artifact.setFile( f );
|
artifact.setFile( f );
|
||||||
project.setVersion( artifact.getVersion() );
|
project.setVersion( artifact.getVersion() );
|
||||||
|
@ -440,9 +423,6 @@ public class DefaultMavenProjectBuilder
|
||||||
externalProfileManager ) );
|
externalProfileManager ) );
|
||||||
project.setActiveProfiles( projectProfiles );
|
project.setActiveProfiles( projectProfiles );
|
||||||
|
|
||||||
projectWorkspace.storeProjectByCoordinate( project );
|
|
||||||
projectWorkspace.storeProjectByFile( project );
|
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,12 +56,7 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jason van Zyl
|
* @author Jason van Zyl
|
||||||
|
@ -149,6 +144,8 @@ public class MavenMetadataSource
|
||||||
return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion();
|
return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HashMap<String, MavenProject> hm = new HashMap<String, MavenProject>();
|
||||||
|
|
||||||
private ProjectRelocation retrieveRelocatedProject( Artifact artifact, ArtifactRepository localRepository,
|
private ProjectRelocation retrieveRelocatedProject( Artifact artifact, ArtifactRepository localRepository,
|
||||||
List<ArtifactRepository> remoteRepositories )
|
List<ArtifactRepository> remoteRepositories )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
|
@ -184,45 +181,56 @@ public class MavenMetadataSource
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
project =
|
|
||||||
mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository );
|
|
||||||
}
|
|
||||||
catch ( InvalidProjectModelException e )
|
|
||||||
{
|
|
||||||
handleInvalidOrMissingMavenPOM( artifact, e );
|
|
||||||
|
|
||||||
if ( getLogger().isDebugEnabled() )
|
if(hm.containsKey(pomArtifact.getId()))
|
||||||
|
{
|
||||||
|
project = hm.get(pomArtifact.getId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
getLogger().debug( "Reason: " + e.getMessage() );
|
project =
|
||||||
|
mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository );
|
||||||
|
hm.put(pomArtifact.getId(), project);
|
||||||
|
|
||||||
ModelValidationResult validationResult = e.getValidationResult();
|
|
||||||
|
|
||||||
if ( validationResult != null )
|
|
||||||
{
|
|
||||||
getLogger().debug( "\nValidation Errors:" );
|
|
||||||
for ( Iterator i = validationResult.getMessages().iterator(); i.hasNext(); )
|
|
||||||
{
|
|
||||||
getLogger().debug( i.next().toString() );
|
|
||||||
}
|
|
||||||
getLogger().debug( "\n" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getLogger().debug( "", e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch ( InvalidProjectModelException e )
|
||||||
|
{
|
||||||
|
handleInvalidOrMissingMavenPOM( artifact, e );
|
||||||
|
|
||||||
project = null;
|
if ( getLogger().isDebugEnabled() )
|
||||||
}
|
{
|
||||||
catch ( ProjectBuildingException e )
|
getLogger().debug( "Reason: " + e.getMessage() );
|
||||||
{
|
|
||||||
handleInvalidOrMissingMavenPOM( artifact, e );
|
|
||||||
|
|
||||||
project = null;
|
ModelValidationResult validationResult = e.getValidationResult();
|
||||||
|
|
||||||
|
if ( validationResult != null )
|
||||||
|
{
|
||||||
|
getLogger().debug( "\nValidation Errors:" );
|
||||||
|
for ( Iterator i = validationResult.getMessages().iterator(); i.hasNext(); )
|
||||||
|
{
|
||||||
|
getLogger().debug( i.next().toString() );
|
||||||
|
}
|
||||||
|
getLogger().debug( "\n" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getLogger().debug( "", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project = null;
|
||||||
|
}
|
||||||
|
catch ( ProjectBuildingException e )
|
||||||
|
{
|
||||||
|
handleInvalidOrMissingMavenPOM( artifact, e );
|
||||||
|
|
||||||
|
project = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( project != null )
|
if ( project != null )
|
||||||
{
|
{
|
||||||
Relocation relocation = null;
|
Relocation relocation = null;
|
||||||
|
|
Loading…
Reference in New Issue