You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by na...@apache.org on 2022/01/12 15:18:19 UTC
[ignite] branch master updated: IGNITE-16270 Update Maven Utils to obtain repositories list through effective pom. (#9729)
This is an automated email from the ASF dual-hosted git repository.
namelchev 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 4ca46ce IGNITE-16270 Update Maven Utils to obtain repositories list through effective pom. (#9729)
4ca46ce is described below
commit 4ca46ced62344729d16613b738d59544a6131772
Author: Mikhail Petrov <32...@users.noreply.github.com>
AuthorDate: Wed Jan 12 18:18:01 2022 +0300
IGNITE-16270 Update Maven Utils to obtain repositories list through effective pom. (#9729)
---
modules/compatibility/pom.xml | 6 ++++++
.../testframework/util/MavenUtils.java | 24 ++++++++++++++--------
parent/pom.xml | 1 +
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/modules/compatibility/pom.xml b/modules/compatibility/pom.xml
index 5df6a92..b7c26b8 100644
--- a/modules/compatibility/pom.xml
+++ b/modules/compatibility/pom.xml
@@ -61,6 +61,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>${maven.model.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ignite-core</artifactId>
<version>${project.version}</version>
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 44cf80d..a3d1b4f 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
@@ -18,25 +18,28 @@
package org.apache.ignite.compatibility.testframework.util;
import java.io.File;
+import java.io.FileInputStream;
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.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
import com.google.common.base.Charsets;
import com.google.common.io.CharStreams;
import org.apache.ignite.internal.util.GridStringBuilder;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.RepositoryBase;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -161,15 +164,18 @@ public class MavenUtils {
if (!prjPomFile.exists())
return Collections.emptyList();
- String out = exec(buildMvnCommand() + " -f " + workDir + ' ' + MAVEN_DEPENDENCY_PLUGIN + ":list-repositories");
+ Path outPath = Files.createTempFile("effective-pom", "");
- String urlPrefix = "url:";
+ try {
+ exec(buildMvnCommand() + " -f " + workDir + " help:effective-pom -Doutput=" + outPath.toAbsolutePath());
+
+ Model model = new MavenXpp3Reader().read(new FileInputStream(outPath.toFile()));
- return Arrays.stream(out.split(U.nl()))
- .map(String::trim)
- .filter(s -> s.startsWith(urlPrefix))
- .map(s -> s.substring(urlPrefix.length()).trim())
- .collect(Collectors.toList());
+ return F.transform(model.getRepositories(), RepositoryBase::getUrl);
+ }
+ finally {
+ Files.deleteIfExists(outPath);
+ }
}
/**
diff --git a/parent/pom.xml b/parent/pom.xml
index 6f4dc21..a4c49e4 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -105,6 +105,7 @@
<lz4.version>1.5.0</lz4.version>
<maven.bundle.plugin.version>3.5.0</maven.bundle.plugin.version>
<maven.checkstyle.plugin.version>3.1.1</maven.checkstyle.plugin.version>
+ <maven.model.version>3.8.4</maven.model.version>
<checkstyle.puppycrawl.version>8.45</checkstyle.puppycrawl.version>
<mockito.version>3.4.6</mockito.version>
<mysql.connector.version>8.0.26</mysql.connector.version>