mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-15 15:59:17 +00:00
Workaround for #281
This commit is contained in:
@@ -87,6 +87,8 @@
|
||||
<mrm.repository.url>${mrm.repository.url}</mrm.repository.url>
|
||||
<os.detected.name>${os.detected.name}</os.detected.name>
|
||||
<os.detected.arch>${os.detected.arch}</os.detected.arch>
|
||||
<mvnd.test.hostLocalMavenRepo>${settings.localRepository}</mvnd.test.hostLocalMavenRepo>
|
||||
<surefire.version>${surefire.version}</surefire.version>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
@@ -168,6 +170,8 @@
|
||||
<mrm.repository.url>${mrm.repository.url}</mrm.repository.url>
|
||||
<os.detected.name>${os.detected.name}</os.detected.name>
|
||||
<os.detected.arch>${os.detected.arch}</os.detected.arch>
|
||||
<mvnd.test.hostLocalMavenRepo>${settings.localRepository}</mvnd.test.hostLocalMavenRepo>
|
||||
<surefire.version>${surefire.version}</surefire.version>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@@ -16,6 +16,7 @@
|
||||
package org.mvndaemon.mvnd.junit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@@ -191,8 +192,21 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
|
||||
+ mvndHome);
|
||||
}
|
||||
final Path mvndPropertiesPath = testDir.resolve("mvnd.properties");
|
||||
|
||||
final Path localMavenRepository = deleteDir(testDir.resolve("local-maven-repo"));
|
||||
final Path settingsPath = createSettings(testDir.resolve("settings.xml"));
|
||||
String mrmRepoUrl = System.getProperty("mrm.repository.url");
|
||||
if ("".equals(mrmRepoUrl)) {
|
||||
mrmRepoUrl = null;
|
||||
}
|
||||
final Path settingsPath;
|
||||
if (mrmRepoUrl == null) {
|
||||
LOG.info("Building without mrm-maven-plugin");
|
||||
settingsPath = null;
|
||||
prefillLocalRepo(localMavenRepository);
|
||||
} else {
|
||||
LOG.info("Building with mrm-maven-plugin");
|
||||
settingsPath = createSettings(testDir.resolve("settings.xml"), mrmRepoUrl);
|
||||
}
|
||||
final Path logback = Paths.get("src/test/resources/logback/logback.xml").toAbsolutePath();
|
||||
final Path home = deleteDir(testDir.resolve("home"));
|
||||
final TestParameters parameters = new TestParameters(
|
||||
@@ -213,13 +227,28 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
|
||||
return new MvndResource(parameters, registry, isNative, timeoutMs);
|
||||
}
|
||||
|
||||
static Path createSettings(Path settingsPath) {
|
||||
final String mrmRepoUrl = System.getProperty("mrm.repository.url");
|
||||
if (mrmRepoUrl == null || mrmRepoUrl.isEmpty()) {
|
||||
LOG.info("Building without mrm-maven-plugin");
|
||||
return null;
|
||||
private static void prefillLocalRepo(final Path localMavenRepository) {
|
||||
/* Workaround for https://github.com/mvndaemon/mvnd/issues/281 */
|
||||
final String surefireVersion = System.getProperty("surefire.version");
|
||||
final Path hostLocalMavenRepo = Paths.get(System.getProperty("mvnd.test.hostLocalMavenRepo"));
|
||||
Stream.of(
|
||||
"org/apache/maven/surefire/surefire-providers/" + surefireVersion + "/surefire-providers-"
|
||||
+ surefireVersion + ".pom",
|
||||
"org/apache/maven/surefire/surefire-providers/" + surefireVersion + "/surefire-providers-"
|
||||
+ surefireVersion + ".pom.sha1")
|
||||
.forEach(relPath -> {
|
||||
final Path src = hostLocalMavenRepo.resolve(relPath);
|
||||
final Path dest = localMavenRepository.resolve(relPath);
|
||||
try {
|
||||
Files.createDirectories(dest.getParent());
|
||||
Files.copy(src, dest);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
LOG.info("Building with mrm-maven-plugin");
|
||||
});
|
||||
}
|
||||
|
||||
static Path createSettings(Path settingsPath, String mrmRepoUrl) {
|
||||
final Path settingsTemplatePath = Paths.get("src/test/resources/settings-template.xml");
|
||||
try {
|
||||
final String template = Files.readString(settingsTemplatePath);
|
||||
|
2
pom.xml
2
pom.xml
@@ -59,7 +59,7 @@
|
||||
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
|
||||
<maven-install-plugin.version>2.4</maven-install-plugin.version>
|
||||
<mrm.version>1.2.0</mrm.version>
|
||||
<surefire.version>3.0.0-M5</surefire.version>
|
||||
<surefire.version>2.22.2</surefire.version>
|
||||
<takari-lifecycle.version>1.13.9</takari-lifecycle.version>
|
||||
<takari-provisio.version>1.0.15</takari-provisio.version>
|
||||
|
||||
|
Reference in New Issue
Block a user