Add a ProjectBuilder that does not cache snapshots longer than the reactor build, fixes #9

This commit is contained in:
Guillaume Nodet
2019-10-18 14:03:44 +02:00
parent 6f165eba44
commit 2a1eae69ac
3 changed files with 1101 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -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;
}
}

View File

@@ -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>