diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index e316a933b..f13f4e455 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -87,6 +87,8 @@ ${mrm.repository.url} ${os.detected.name} ${os.detected.arch} + ${settings.localRepository} + ${surefire.version} @@ -168,6 +170,8 @@ ${mrm.repository.url} ${os.detected.name} ${os.detected.arch} + ${settings.localRepository} + ${surefire.version} diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/MvndTestExtension.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/MvndTestExtension.java index 7982fae71..dfb9eec9a 100644 --- a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/MvndTestExtension.java +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/MvndTestExtension.java @@ -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 static MvndResource create(String className, String rawProjectDir, boolea + 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 static MvndResource create(String className, String rawProjectDir, boolea 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; - } - LOG.info("Building with mrm-maven-plugin"); + 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); + } + }); + } + + 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); diff --git a/pom.xml b/pom.xml index 8eccf1bb2..07a11a6b9 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ 3.2.0 2.4 1.2.0 - 3.0.0-M5 + 2.22.2 1.13.9 1.0.15