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