mirror of https://github.com/apache/maven.git
[MNG-6311] Implement class-level ModelCache in DefaultProjectBuilder to solve slow pom resolutions
Fix by: David Churcher
This commit is contained in:
parent
01f098efd1
commit
8bc3c207d0
|
@ -105,6 +105,8 @@ public class DefaultProjectBuilder
|
||||||
@Requirement
|
@Requirement
|
||||||
private ProjectDependenciesResolver dependencyResolver;
|
private ProjectDependenciesResolver dependencyResolver;
|
||||||
|
|
||||||
|
private final ReactorModelCache modelCache = new ReactorModelCache();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// MavenProjectBuilder Implementation
|
// MavenProjectBuilder Implementation
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -113,14 +115,14 @@ public class DefaultProjectBuilder
|
||||||
public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest request )
|
public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest request )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
return build( pomFile, new FileModelSource( pomFile ), new InternalConfig( request, null, null ) );
|
return build( pomFile, new FileModelSource( pomFile ), new InternalConfig( request, null ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectBuildingResult build( ModelSource modelSource, ProjectBuildingRequest request )
|
public ProjectBuildingResult build( ModelSource modelSource, ProjectBuildingRequest request )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
return build( null, modelSource, new InternalConfig( request, null, null ) );
|
return build( null, modelSource, new InternalConfig( request, null ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProjectBuildingResult build( File pomFile, ModelSource modelSource, InternalConfig config )
|
private ProjectBuildingResult build( File pomFile, ModelSource modelSource, InternalConfig config )
|
||||||
|
@ -291,7 +293,7 @@ public class DefaultProjectBuilder
|
||||||
org.eclipse.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact );
|
org.eclipse.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact );
|
||||||
pomArtifact = ArtifactDescriptorUtils.toPomArtifact( pomArtifact );
|
pomArtifact = ArtifactDescriptorUtils.toPomArtifact( pomArtifact );
|
||||||
|
|
||||||
InternalConfig config = new InternalConfig( request, null, null );
|
InternalConfig config = new InternalConfig( request, null );
|
||||||
|
|
||||||
boolean localProject;
|
boolean localProject;
|
||||||
|
|
||||||
|
@ -353,9 +355,7 @@ public class DefaultProjectBuilder
|
||||||
|
|
||||||
ReactorModelPool modelPool = new ReactorModelPool();
|
ReactorModelPool modelPool = new ReactorModelPool();
|
||||||
|
|
||||||
ReactorModelCache modelCache = new ReactorModelCache();
|
InternalConfig config = new InternalConfig( request, modelPool );
|
||||||
|
|
||||||
InternalConfig config = new InternalConfig( request, modelPool, modelCache );
|
|
||||||
|
|
||||||
Map<String, MavenProject> projectIndex = new HashMap<>( 256 );
|
Map<String, MavenProject> projectIndex = new HashMap<>( 256 );
|
||||||
|
|
||||||
|
@ -943,11 +943,11 @@ public class DefaultProjectBuilder
|
||||||
|
|
||||||
private final ReactorModelCache modelCache;
|
private final ReactorModelCache modelCache;
|
||||||
|
|
||||||
InternalConfig( ProjectBuildingRequest request, ReactorModelPool modelPool, ReactorModelCache modelCache )
|
InternalConfig( ProjectBuildingRequest request, ReactorModelPool modelPool )
|
||||||
{
|
{
|
||||||
this.request = request;
|
this.request = request;
|
||||||
this.modelPool = modelPool;
|
this.modelPool = modelPool;
|
||||||
this.modelCache = modelCache;
|
this.modelCache = getModelCache();
|
||||||
session =
|
session =
|
||||||
LegacyLocalRepositoryManager.overlay( request.getLocalRepository(), request.getRepositorySession(),
|
LegacyLocalRepositoryManager.overlay( request.getLocalRepository(), request.getRepositorySession(),
|
||||||
repoSystem );
|
repoSystem );
|
||||||
|
@ -956,4 +956,9 @@ public class DefaultProjectBuilder
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ReactorModelCache getModelCache()
|
||||||
|
{
|
||||||
|
return this.modelCache;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,11 @@ package org.apache.maven.project;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.maven.model.building.ModelCache;
|
import org.apache.maven.model.building.ModelCache;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple model cache used to accelerate model building during a reactor build.
|
* A simple model cache used to accelerate model building during a reactor build.
|
||||||
*
|
*
|
||||||
|
@ -33,7 +33,7 @@ class ReactorModelCache
|
||||||
implements ModelCache
|
implements ModelCache
|
||||||
{
|
{
|
||||||
|
|
||||||
private final Map<CacheKey, Object> models = new HashMap<>( 256 );
|
private final Map<CacheKey, Object> models = new ConcurrentHashMap<>( 256 );
|
||||||
|
|
||||||
public Object get( String groupId, String artifactId, String version, String tag )
|
public Object get( String groupId, String artifactId, String version, String tag )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue