This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git
The following commit(s) were added to refs/heads/master by this push: new 0b55c8f3 Add property to disable model caching 0b55c8f3 is described below commit 0b55c8f3e6f3937d253c3362e78ec540225c2baf Author: Stefan Oehme <st.oe...@gmail.com> AuthorDate: Sun Feb 26 18:10:14 2023 +0100 Add property to disable model caching This is mostly for the integration tests of the Gradle Enterprise Maven extension, which heavily test dependency resolution and reuse the same GAVs in many test, e.g. a:b:1.0. It would be a lot of effort to rewrite all those tests and a shame to restart the daemon every time. So I wanted to ask if you'd consider this flag to disable the caching altogether. --- common/src/main/java/org/mvndaemon/mvnd/common/Environment.java | 7 +++++++ .../java/org/apache/maven/project/SnapshotModelCacheFactory.java | 8 +++++++- dist/src/main/distro/bin/mvnd-bash-completion.bash | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java b/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java index 65dcddcc..49d5e9a1 100644 --- a/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java +++ b/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java @@ -163,6 +163,13 @@ public enum Environment { * non-native clients and is useful mostly for debugging. */ MVND_NO_DAEMON("mvnd.noDaemon", "MVND_NO_DAEMON", Boolean.FALSE, OptionType.BOOLEAN, Flags.DISCRIMINATING), + + /** + * If <code>true</code>, the daemon will not use its in-memory metadata cache and instead re-read the + * metadata from the pom.xml files in the local repository. This is mostly useful for testing purposes. + */ + MVND_NO_MODEL_CACHE("mvnd.noModelCache", null, Boolean.FALSE, OptionType.BOOLEAN, Flags.OPTIONAL), + /** * If <code>true</code>, the daemon will be launched in debug mode with the following JVM argument: * <code>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000</code>; otherwise the debug argument is diff --git a/daemon/src/main/java/org/apache/maven/project/SnapshotModelCacheFactory.java b/daemon/src/main/java/org/apache/maven/project/SnapshotModelCacheFactory.java index a070c7c5..fe285af6 100644 --- a/daemon/src/main/java/org/apache/maven/project/SnapshotModelCacheFactory.java +++ b/daemon/src/main/java/org/apache/maven/project/SnapshotModelCacheFactory.java @@ -29,6 +29,8 @@ import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.sisu.Priority; +import static org.mvndaemon.mvnd.common.Environment.MVND_NO_MODEL_CACHE; + @Singleton @Named @Priority(10) @@ -45,6 +47,10 @@ public class SnapshotModelCacheFactory implements ModelCacheFactory { @Override public ModelCache createCache(RepositorySystemSession session) { - return new SnapshotModelCache(globalCache, factory.createCache(session)); + boolean noModelCache = + Boolean.parseBoolean(MVND_NO_MODEL_CACHE.asOptional().orElse(MVND_NO_MODEL_CACHE.getDefault())); + ModelCache reactorCache = factory.createCache(session); + ModelCache globalCache = noModelCache ? reactorCache : this.globalCache; + return new SnapshotModelCache(globalCache, reactorCache); } } diff --git a/dist/src/main/distro/bin/mvnd-bash-completion.bash b/dist/src/main/distro/bin/mvnd-bash-completion.bash index 50f77891..0dde19ff 100755 --- a/dist/src/main/distro/bin/mvnd-bash-completion.bash +++ b/dist/src/main/distro/bin/mvnd-bash-completion.bash @@ -218,7 +218,7 @@ _mvnd() local mvnd_opts="-1" local mvnd_long_opts="--color|--completion|--purge|--raw-streams|--serial|--status|--stop" - local mvnd_properties="-Djava.home|-Djdk.java.options|-Dmaven.multiModuleProjectDirectory|-Dmaven.repo.local|-Dmaven.settings|-Dmvnd.buildTime|-Dmvnd.builder|-Dmvnd.cancelConnectTimeout|-Dmvnd.connectTimeout|-Dmvnd.daemonStorage|-Dmvnd.debug|-Dmvnd.debug.address|-Dmvnd.duplicateDaemonGracePeriod|-Dmvnd.enableAssertions|-Dmvnd.expirationCheckDelay|-Dmvnd.home|-Dmvnd.idleTimeout|-Dmvnd.jvmArgs|-Dmvnd.keepAlive|-Dmvnd.logPurgePeriod|-Dmvnd.logback|-Dmvnd.maxHeapSize|-Dmvnd.maxLostKeepAl [...] + local mvnd_properties="-Djava.home|-Djdk.java.options|-Dmaven.multiModuleProjectDirectory|-Dmaven.repo.local|-Dmaven.settings|-Dmvnd.buildTime|-Dmvnd.builder|-Dmvnd.cancelConnectTimeout|-Dmvnd.connectTimeout|-Dmvnd.daemonStorage|-Dmvnd.debug|-Dmvnd.debug.address|-Dmvnd.duplicateDaemonGracePeriod|-Dmvnd.enableAssertions|-Dmvnd.expirationCheckDelay|-Dmvnd.home|-Dmvnd.idleTimeout|-Dmvnd.jvmArgs|-Dmvnd.keepAlive|-Dmvnd.logPurgePeriod|-Dmvnd.logback|-Dmvnd.maxHeapSize|-Dmvnd.maxLostKeepAl [...] local opts="-am|-amd|-B|-C|-c|-cpu|-D|-e|-emp|-ep|-f|-fae|-ff|-fn|-gs|-h|-l|-N|-npr|-npu|-nsu|-o|-P|-pl|-q|-rf|-s|-T|-t|-U|-up|-V|-v|-X|${mvnd_opts}" local long_opts="--also-make|--also-make-dependents|--batch-mode|--strict-checksums|--lax-checksums|--check-plugin-updates|--define|--errors|--encrypt-master-password|--encrypt-password|--file|--fail-at-end|--fail-fast|--fail-never|--global-settings|--help|--log-file|--non-recursive|--no-plugin-registry|--no-plugin-updates|--no-snapshot-updates|--offline|--activate-profiles|--projects|--quiet|--resume-from|--settings|--threads|--toolchains|--update-snapshots|--update-plugins|--show-v [...]