diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 8ce7d00d00..4f5686b137 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -107,7 +107,9 @@ public class DefaultMavenProjectBuilder public MavenProject build( File pomFile, ProjectBuilderConfiguration configuration ) throws ProjectBuildingException { - MavenProject project = projectCache.get( pomFile.getAbsolutePath() ); + String cacheKey = getCacheKey( pomFile, configuration ); + + MavenProject project = projectCache.get( cacheKey ); if ( project != null ) { @@ -211,11 +213,19 @@ public class DefaultMavenProjectBuilder project.setFile( pomFile ); project.setActiveProfiles( projectProfiles ); - projectCache.put( pomFile.getAbsolutePath(), project ); + projectCache.put( cacheKey, project ); return project; } + private String getCacheKey( File pomFile, ProjectBuilderConfiguration configuration ) + { + StringBuilder buffer = new StringBuilder( 256 ); + buffer.append( pomFile.getAbsolutePath() ); + buffer.append( '/' ).append( pomFile.lastModified() ); + return buffer.toString(); + } + public MavenProject buildFromRepository( Artifact artifact, ProjectBuilderConfiguration configuration ) throws ProjectBuildingException {