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

mpetrov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new df0fee1ca45 IGNITE-23094 Added support for custom Maven settings file 
path for all commands in Compatibility tests. (#11499)
df0fee1ca45 is described below

commit df0fee1ca45ab0830a8963f7d98c5ed36bfdd446
Author: Mikhail Petrov <[email protected]>
AuthorDate: Fri Aug 30 10:43:46 2024 +0300

    IGNITE-23094 Added support for custom Maven settings file path for all 
commands in Compatibility tests. (#11499)
---
 .../testframework/util/MavenUtils.java             | 53 ++++++++++------------
 1 file changed, 24 insertions(+), 29 deletions(-)

diff --git 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
index 3926697b217..909c49c55f7 100644
--- 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
+++ 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
@@ -23,7 +23,6 @@ import java.io.InputStreamReader;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.concurrent.Callable;
@@ -43,8 +42,6 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.internal.util.lang.GridFunc.isEmpty;
-
 /**
  * Provides some useful methods to work with Maven.
  */
@@ -55,12 +52,6 @@ public class MavenUtils {
     /** */
     private static final String MAVEN_DEPENDENCY_PLUGIN = 
"org.apache.maven.plugins:maven-dependency-plugin:3.2.0";
 
-    /** */
-    private static final String GG_MVN_REPO = 
"http://www.gridgainsystems.com/nexus/content/repositories/external";;
-
-    /** Set this flag to true if running PDS compatibility tests locally. */
-    private static boolean useGgRepo;
-
     /**
      * Gets a path to an artifact with given version and 
groupId=org.apache.ignite and artifactId={@code artifactId}.
      * <br>
@@ -187,29 +178,12 @@ public class MavenUtils {
     private static void downloadArtifact(String artifact) throws Exception {
         X.println("Downloading artifact... Identifier: " + artifact);
 
-        // Default platform independ path for maven settings file.
-        Path locProxyMavenSettings = 
Paths.get(System.getProperty("user.home"), ".m2", "local-proxy.xml");
-
-        String locProxyMavenSettingsFromEnv = 
System.getenv("LOCAL_PROXY_MAVEN_SETTINGS");
-
         GridStringBuilder mavenCmdArgs = new SB(" 
").a(MAVEN_DEPENDENCY_PLUGIN).a(":get -Dartifact=" + artifact);
 
-        if (!isEmpty(locProxyMavenSettingsFromEnv))
-            locProxyMavenSettings = Paths.get(locProxyMavenSettingsFromEnv);
-
-        if (Files.exists(locProxyMavenSettings))
-            mavenCmdArgs.a(" -s " + locProxyMavenSettings.toString());
-        else {
-            Collection<String> repos = new ArrayList<>();
-
-            if (useGgRepo)
-                repos.add(GG_MVN_REPO);
+        Collection<String> repos = mavenProjectRepositories();
 
-            repos.addAll(mavenProjectRepositories());
-
-            if (!repos.isEmpty())
-                mavenCmdArgs.a(" -DremoteRepositories=").a(String.join(",", 
repos));
-        }
+        if (!repos.isEmpty())
+            mavenCmdArgs.a(" -DremoteRepositories=").a(String.join(",", 
repos));
 
         exec(buildMvnCommand() + mavenCmdArgs.toString());
 
@@ -268,6 +242,27 @@ public class MavenUtils {
      * @return Maven executable command.
      */
     private static String buildMvnCommand() {
+        String mvnCmd = resolveMavenApplicationPath();
+
+        Path mvnSettingsFilePath = resolveMavenSettingsFilePath();
+
+        if (Files.exists(mvnSettingsFilePath))
+            mvnCmd += " -s " + mvnSettingsFilePath;
+
+        return mvnCmd;
+    }
+
+    /** */
+    private static Path resolveMavenSettingsFilePath() {
+        String settingsPathEnv = System.getenv("LOCAL_PROXY_MAVEN_SETTINGS");
+
+        return F.isEmpty(settingsPathEnv)
+            ? Paths.get(System.getProperty("user.home"), ".m2", 
"local-proxy.xml")
+            : Paths.get(settingsPathEnv);
+    }
+
+    /** */
+    private static String resolveMavenApplicationPath() {
         String m2Home = System.getenv("M2_HOME");
 
         if (m2Home == null)

Reply via email to