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

rombert pushed a commit to branch issue/SLING-12932
in repository 
https://gitbox.apache.org/repos/asf/sling-feature-launcher-maven-plugin.git

commit 41517e1e67ef0a363ae2545ded52fb40d11d916f
Author: Robert Munteanu <[email protected]>
AuthorDate: Fri Sep 5 16:46:57 2025 +0200

    SLING-12932 - Explicitly configure the local maven repository when launching
    
    Follow the standard behaviour of the feature launcher but use the actual 
local repository URL
    reported by Maven.
---
 .../sling/maven/feature/launcher/StartMojo.java    | 31 +++++++++++++++++-----
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/maven/feature/launcher/StartMojo.java 
b/src/main/java/org/apache/sling/maven/feature/launcher/StartMojo.java
index e7a1734..45d3b4a 100644
--- a/src/main/java/org/apache/sling/maven/feature/launcher/StartMojo.java
+++ b/src/main/java/org/apache/sling/maven/feature/launcher/StartMojo.java
@@ -34,6 +34,7 @@ import java.util.StringJoiner;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import 
org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.VersionRange;
@@ -103,9 +104,9 @@ public class StartMojo extends AbstractMojo {
      * </environmentVariables>}
      * </pre>
      * 
-     * <p>The repository URLs replace the default values set by the Feature 
Launcher. These default values are:
+     * <p>If no repository URLs are configured the following defaults are 
used, in order:
      * <ul>
-     *   <li>The local Maven repository at $HOME/.m2/repository</li>
+     *   <li>The local Maven repository</li>
      *   <li>The Maven Central repository</li>
      *   <li>The Apache Snapshots repository</li>
      * </ul>
@@ -116,6 +117,9 @@ public class StartMojo extends AbstractMojo {
 
     @Component
     private ArtifactResolver resolver;
+    
+    @Parameter(defaultValue = "${localRepository}", readonly = true)
+    private ArtifactRepository localRepository;
 
     @Parameter(defaultValue = "${project.remotePluginRepositories}", readonly 
= true)
     private List<RemoteRepository> remoteRepos;
@@ -245,12 +249,27 @@ public class StartMojo extends AbstractMojo {
                     args.add("-jar");
                     args.add(launcher.getAbsolutePath());
                 }
+                
+                List<String> repositoryUrls;
+                
                 if ( launch.getRepositoryUrls() != null && 
!launch.getRepositoryUrls().isEmpty() ) {
-                    args.add("-u");
-                    StringJoiner joiner = new StringJoiner(",");
-                    launch.getRepositoryUrls().forEach( joiner::add );
-                    args.add(joiner.toString());
+                    repositoryUrls = launch.getRepositoryUrls();
+                } else {
+                    // replicate the behaviour from 
org.apache.sling.feature.io.artifacts.ArtifactManager
+                    // but pass in the currently configured local repository. 
The ArtifactManager checks for the local
+                    // configuration file $HOME/.m2/settings.xml but cannot 
find out if the Maven process was invoked
+                    // with a maven.repo.local argument
+                    repositoryUrls = new ArrayList<>();
+                    repositoryUrls.add("file://" + 
localRepository.getBasedir());
+                    repositoryUrls.add("https://repo1.maven.org/maven2";);
+                    
repositoryUrls.add("https://repository.apache.org/content/group/snapshots";);
                 }
+                
+                args.add("-u");
+                StringJoiner joiner = new StringJoiner(",");
+                repositoryUrls.forEach( joiner::add );
+                args.add(joiner.toString());
+                
                 args.add("-f");
                 args.add(featureFile.getAbsolutePath());
                 args.add("-p");

Reply via email to