mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-12-09 01:02:21 +08:00
Add a ProjectBuilder that does not cache snapshots longer than the reactor build, fixes #9
This commit is contained in:
1073
src/main/java/org/apache/maven/project/CachingProjectBuilder.java
Normal file
1073
src/main/java/org/apache/maven/project/CachingProjectBuilder.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
package org.apache.maven.project;
|
||||
|
||||
import org.apache.maven.model.building.ModelCache;
|
||||
|
||||
public class SnapshotModelCache implements ModelCache {
|
||||
|
||||
private final ModelCache globalCache;
|
||||
private final ModelCache reactorCache;
|
||||
|
||||
public SnapshotModelCache(ModelCache globalCache) {
|
||||
this.globalCache = globalCache;
|
||||
this.reactorCache = new ReactorModelCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String groupId, String artifactId, String version, String tag, Object data) {
|
||||
getDelegate(version).put(groupId, artifactId, version, tag, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String groupId, String artifactId, String version, String tag) {
|
||||
return getDelegate(version).get(groupId, artifactId, version, tag);
|
||||
}
|
||||
|
||||
private ModelCache getDelegate(String version) {
|
||||
return version.contains("SNAPSHOT") ? reactorCache : globalCache;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
<implementation>org.jboss.fuse.mvnd.plugin.CliPluginRealmCache</implementation>
|
||||
<isolated-realm>false</isolated-realm>
|
||||
</component>
|
||||
<!--
|
||||
<component>
|
||||
<role>org.apache.maven.project.ProjectBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
@@ -48,6 +47,5 @@
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
-->
|
||||
</components>
|
||||
</component-set>
|
||||
|
||||
Reference in New Issue
Block a user