From df0fee1ca45ab0830a8963f7d98c5ed36bfdd446 Mon Sep 17 00:00:00 2001
From: Mikhail Petrov <32207922+petrov-mg@users.noreply.github.com>
Date: Fri, 30 Aug 2024 10:43:46 +0300
Subject: [PATCH] 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 3926697b2176c..909c49c55f7ef 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.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.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}.
*
@@ -187,29 +178,12 @@ private static Collection mavenProjectRepositories() throws Exception {
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 repos = new ArrayList<>();
-
- if (useGgRepo)
- repos.add(GG_MVN_REPO);
+ Collection 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 @@ private static String exec(String cmd) throws Exception {
* @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)