This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git

commit f191c652f531073951ebc39d6f400ebc4ff381a8
Author: Guillaume Nodet <gno...@gmail.com>
AuthorDate: Thu Nov 7 19:10:14 2024 +0100

    Restore ModelCacheFactory
---
 daemon/pom.xml                                     |  5 +++++
 .../apache/maven/project/SnapshotModelCache.java   |  9 +++++++--
 .../maven/project/SnapshotModelCacheFactory.java   | 23 ++++++++++------------
 pom.xml                                            |  5 +++++
 4 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/daemon/pom.xml b/daemon/pom.xml
index 7c07b30d..959e1470 100644
--- a/daemon/pom.xml
+++ b/daemon/pom.xml
@@ -33,6 +33,7 @@
   <properties>
     <!-- If using release, sun.misc is not reachable (see SignalHelper) -->
     <!--    <maven.compiler.release />-->
+    <maven.compiler.proc>full</maven.compiler.proc>
   </properties>
 
   <dependencies>
@@ -60,6 +61,10 @@
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-cli</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-api-di</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-interactivity-api</artifactId>
diff --git 
a/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java 
b/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java
index e27bf76e..0ab483af 100644
--- a/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java
+++ b/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java
@@ -21,8 +21,8 @@ package org.apache.maven.project;
 import java.util.Objects;
 import java.util.function.Supplier;
 
-import org.apache.maven.building.Source;
-import org.apache.maven.model.building.ModelCache;
+import org.apache.maven.api.services.Source;
+import org.apache.maven.api.services.model.ModelCache;
 
 public class SnapshotModelCache implements ModelCache {
 
@@ -44,6 +44,11 @@ public class SnapshotModelCache implements ModelCache {
         return reactorCache.computeIfAbsent(path, tag, data);
     }
 
+    @Override
+    public void clear() {
+        reactorCache.clear();
+    }
+
     private ModelCache getDelegate(String version) {
         return version.contains("SNAPSHOT") || version.contains("${") ? 
reactorCache : globalCache;
     }
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 fe285af6..d276439f 100644
--- 
a/daemon/src/main/java/org/apache/maven/project/SnapshotModelCacheFactory.java
+++ 
b/daemon/src/main/java/org/apache/maven/project/SnapshotModelCacheFactory.java
@@ -18,16 +18,13 @@
  */
 package org.apache.maven.project;
 
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.apache.maven.model.building.ModelCache;
-import org.apache.maven.repository.internal.DefaultModelCacheFactory;
-import org.apache.maven.repository.internal.ModelCacheFactory;
-import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.sisu.Priority;
+import org.apache.maven.api.di.Inject;
+import org.apache.maven.api.di.Named;
+import org.apache.maven.api.di.Priority;
+import org.apache.maven.api.di.Singleton;
+import org.apache.maven.api.services.model.ModelCache;
+import org.apache.maven.api.services.model.ModelCacheFactory;
+import org.apache.maven.internal.impl.model.DefaultModelCacheFactory;
 
 import static org.mvndaemon.mvnd.common.Environment.MVND_NO_MODEL_CACHE;
 
@@ -42,14 +39,14 @@ public class SnapshotModelCacheFactory implements 
ModelCacheFactory {
     @Inject
     public SnapshotModelCacheFactory(DefaultModelCacheFactory factory) {
         this.factory = factory;
-        this.globalCache = factory.createCache(new 
DefaultRepositorySystemSession());
+        this.globalCache = factory.newInstance();
     }
 
     @Override
-    public ModelCache createCache(RepositorySystemSession session) {
+    public ModelCache newInstance() {
         boolean noModelCache =
                 
Boolean.parseBoolean(MVND_NO_MODEL_CACHE.asOptional().orElse(MVND_NO_MODEL_CACHE.getDefault()));
-        ModelCache reactorCache = factory.createCache(session);
+        ModelCache reactorCache = factory.newInstance();
         ModelCache globalCache = noModelCache ? reactorCache : 
this.globalCache;
         return new SnapshotModelCache(globalCache, reactorCache);
     }
diff --git a/pom.xml b/pom.xml
index da542bff..f95870a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -178,6 +178,11 @@
         <artifactId>maven-cli</artifactId>
         <version>${maven.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-api-di</artifactId>
+        <version>${maven.version}</version>
+      </dependency>
       <dependency>
         <groupId>org.apache.maven</groupId>
         <artifactId>maven-jline</artifactId>

Reply via email to