Yet another workaround for #281

This commit is contained in:
Peter Palaga
2021-01-04 17:38:50 +01:00
parent a81aa7c397
commit eb11f64db7
4 changed files with 24 additions and 13 deletions

View File

@@ -89,6 +89,7 @@
<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> <mvnd.test.hostLocalMavenRepo>${settings.localRepository}</mvnd.test.hostLocalMavenRepo>
<surefire.version>${surefire.version}</surefire.version> <surefire.version>${surefire.version}</surefire.version>
<junit-platform-launcher.version>${junit-platform-launcher.version}</junit-platform-launcher.version>
</systemPropertyVariables> </systemPropertyVariables>
</configuration> </configuration>
</plugin> </plugin>
@@ -172,6 +173,7 @@
<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> <mvnd.test.hostLocalMavenRepo>${settings.localRepository}</mvnd.test.hostLocalMavenRepo>
<surefire.version>${surefire.version}</surefire.version> <surefire.version>${surefire.version}</surefire.version>
<junit-platform-launcher.version>${junit-platform-launcher.version}</junit-platform-launcher.version>
</systemPropertyVariables> </systemPropertyVariables>
</configuration> </configuration>
</execution> </execution>

View File

@@ -230,21 +230,29 @@ public class MvndTestExtension implements BeforeAllCallback, BeforeEachCallback,
private static void prefillLocalRepo(final Path localMavenRepository) { private static void prefillLocalRepo(final Path localMavenRepository) {
/* Workaround for https://github.com/mvndaemon/mvnd/issues/281 */ /* Workaround for https://github.com/mvndaemon/mvnd/issues/281 */
final String surefireVersion = System.getProperty("surefire.version"); final String surefireVersion = System.getProperty("surefire.version");
final String junitPlatformLauncherVersion = System.getProperty("junit-platform-launcher.version");
final Path hostLocalMavenRepo = Paths.get(System.getProperty("mvnd.test.hostLocalMavenRepo")); final Path hostLocalMavenRepo = Paths.get(System.getProperty("mvnd.test.hostLocalMavenRepo"));
Stream.of( Stream.of(
"org/apache/maven/surefire/surefire-providers/" + surefireVersion + "/surefire-providers-" "org/apache/maven/surefire/surefire-providers/" + surefireVersion,
+ surefireVersion + ".pom", "org/junit/platform/junit-platform-launcher/" + junitPlatformLauncherVersion)
"org/apache/maven/surefire/surefire-providers/" + surefireVersion + "/surefire-providers-"
+ surefireVersion + ".pom.sha1")
.forEach(relPath -> { .forEach(relPath -> {
final Path src = hostLocalMavenRepo.resolve(relPath); final Path src = hostLocalMavenRepo.resolve(relPath);
final Path dest = localMavenRepository.resolve(relPath); if (Files.isDirectory(src)) {
try (Stream<Path> files = Files.list(src)) {
files.forEach(file -> {
final Path dest = localMavenRepository.resolve(relPath).resolve(file.getFileName());
try { try {
Files.createDirectories(dest.getParent()); Files.createDirectories(dest.getParent());
Files.copy(src, dest); Files.copy(src, dest);
} catch (IOException e) { } catch (IOException e) {
throw new UncheckedIOException(e); throw new UncheckedIOException(e);
} }
});
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}); });
} }

View File

@@ -59,7 +59,8 @@
<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>2.22.2</surefire.version> <surefire.version>2.22.2</surefire.version><!-- keep in sync with junit-platform-launcher.version -->
<junit-platform-launcher.version>1.3.1</junit-platform-launcher.version><!-- keep in sync with 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>