From 94bf2757ca38f5c7a6773d6d4b475b297ab08b10 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Mon, 8 Jul 2024 18:20:29 +0200 Subject: [PATCH] Slight updates --- pom.xml | 21 ++++++++++++++----- takari-plugin-integration-testing/pom.xml | 1 - takari-plugin-testing-its/pom.xml | 5 +++-- .../maven/testing/test/IntegrationTest.java | 4 ++-- .../testing/test/JUnit5IntegrationTests.java | 9 ++++++-- .../maven/testing/test/JUnit5UnitTests.java | 4 ++-- .../src/test/java/basic/IntegrationTest.java | 2 +- takari-plugin-testing/pom.xml | 10 ++++++++- .../maven/testing/executor/MavenRuntime.java | 7 +++++-- .../executor/junit/MavenVersionResolver.java | 6 +++--- 10 files changed, 48 insertions(+), 21 deletions(-) diff --git a/pom.xml b/pom.xml index b551a32..cff21b7 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ io.takari takari - 53 + 55 io.takari.maven.plugins @@ -36,10 +36,10 @@ - 3.9.6 - 0.9.0.M2 + 3.9.8 + 0.9.0.M3 6.0.0 - 1.9.18 + 1.9.21 1.7.36 @@ -53,7 +53,7 @@ org.junit junit-bom - 5.10.2 + 5.10.3 pom import @@ -62,6 +62,16 @@ plexus-utils 3.5.1 + + org.slf4j + slf4j-api + 1.7.36 + + + org.slf4j + slf4j-simple + 1.7.36 + @@ -138,6 +148,7 @@ + org.apache.commons commons-compress diff --git a/takari-plugin-integration-testing/pom.xml b/takari-plugin-integration-testing/pom.xml index 61ecf16..f53e51a 100644 --- a/takari-plugin-integration-testing/pom.xml +++ b/takari-plugin-integration-testing/pom.xml @@ -45,7 +45,6 @@ org.apache.commons commons-compress - diff --git a/takari-plugin-testing-its/pom.xml b/takari-plugin-testing-its/pom.xml index 54227a1..484f7cb 100644 --- a/takari-plugin-testing-its/pom.xml +++ b/takari-plugin-testing-its/pom.xml @@ -109,6 +109,7 @@ org.apache.maven.plugins maven-dependency-plugin + 3.7.1 unpack @@ -117,7 +118,7 @@ generate-test-resources - ${project.build.directory} + ${project.build.directory}/maven-installation org.apache.maven @@ -136,7 +137,7 @@ org.apache.maven apache-maven - 3.9.6 + 3.9.8 bin tar.gz diff --git a/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/IntegrationTest.java b/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/IntegrationTest.java index 62967a8..60bf300 100644 --- a/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/IntegrationTest.java +++ b/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/IntegrationTest.java @@ -33,7 +33,7 @@ public static List versions() { List parameters = new ArrayList<>(); parameters.add(new Object[] {"3.6.3"}); parameters.add(new Object[] {"3.8.8"}); - parameters.add(new Object[] {"3.9.6"}); + parameters.add(new Object[] {"3.9.8"}); return parameters; } @@ -46,7 +46,7 @@ public static List versions() { public IntegrationTest(String version) throws Exception { this.version = version; - File mavenHome = new File("target/apache-maven-" + version); + File mavenHome = new File("target/maven-installation/apache-maven-" + version); this.maven = MavenRuntime.builder(mavenHome, null).forkedBuilder().build(); } diff --git a/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/JUnit5IntegrationTests.java b/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/JUnit5IntegrationTests.java index 8a43caa..5183001 100644 --- a/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/JUnit5IntegrationTests.java +++ b/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/JUnit5IntegrationTests.java @@ -13,7 +13,11 @@ import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.extension.RegisterExtension; -@MavenInstallations({"target/apache-maven-3.6.3", "target/apache-maven-3.8.8", "target/apache-maven-3.9.6"}) +@MavenInstallations({ + "target/maven-installation/apache-maven-3.6.3", + "target/maven-installation/apache-maven-3.8.8", + "target/maven-installation/apache-maven-3.9.8" +}) public class JUnit5IntegrationTests { @RegisterExtension @@ -36,7 +40,8 @@ void testBasic() throws Exception { "package basic; class TargetVersion { static final String VERSION = \"" + this.version + "\"; }"); this.maven - .forProject(basedir) // + .forProject(basedir) + .withCliOption("-e") // .execute("package") // .assertErrorFreeLog(); } diff --git a/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/JUnit5UnitTests.java b/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/JUnit5UnitTests.java index 6a0bd23..8d1595b 100644 --- a/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/JUnit5UnitTests.java +++ b/takari-plugin-testing-its/src/test/java/io/takari/maven/testing/test/JUnit5UnitTests.java @@ -86,7 +86,7 @@ void testUnitTestHarnessHonoursUserSettings(MavenRuntime maven, String version) static final class MavenVersionsSource implements ArgumentsProvider { private List getMavenVersions() { - return Arrays.asList("3.6.3", "3.8.8", "3.9.6"); + return Arrays.asList("3.6.3", "3.8.8", "3.9.8"); } @Override @@ -94,7 +94,7 @@ public Stream provideArguments(ExtensionContext context) th List mavenVersions = this.getMavenVersions(); List arguments = new ArrayList<>(mavenVersions.size()); for (String version : mavenVersions) { - File mavenHome = new File("target/apache-maven-" + version); + File mavenHome = new File("target/maven-installation/apache-maven-" + version); MavenRuntime maven = MavenRuntime.builder(mavenHome, null).forkedBuilder().build(); arguments.add(Arguments.of(maven, version)); diff --git a/takari-plugin-testing-its/src/test/projects/basic/src/test/java/basic/IntegrationTest.java b/takari-plugin-testing-its/src/test/projects/basic/src/test/java/basic/IntegrationTest.java index 29e135d..8e39484 100644 --- a/takari-plugin-testing-its/src/test/projects/basic/src/test/java/basic/IntegrationTest.java +++ b/takari-plugin-testing-its/src/test/projects/basic/src/test/java/basic/IntegrationTest.java @@ -28,7 +28,7 @@ public IntegrationTest(MavenRuntimeBuilder builder) throws Exception { @Test public void testBasic() throws Exception { File basedir = resources.getBasedir("basic"); - maven.forProject(basedir).execute("validate").assertErrorFreeLog(); + maven.forProject(basedir).withCliOptions("-e").execute("validate").assertErrorFreeLog(); TestResources.assertFilesPresent(basedir, "target/output.txt"); } diff --git a/takari-plugin-testing/pom.xml b/takari-plugin-testing/pom.xml index 26dffe3..48967a2 100644 --- a/takari-plugin-testing/pom.xml +++ b/takari-plugin-testing/pom.xml @@ -34,6 +34,15 @@ org.codehaus.plexus plexus-utils + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + runtime + @@ -111,5 +120,4 @@ provided - diff --git a/takari-plugin-testing/src/main/java/io/takari/maven/testing/executor/MavenRuntime.java b/takari-plugin-testing/src/main/java/io/takari/maven/testing/executor/MavenRuntime.java index 0ba9d21..e952241 100644 --- a/takari-plugin-testing/src/main/java/io/takari/maven/testing/executor/MavenRuntime.java +++ b/takari-plugin-testing/src/main/java/io/takari/maven/testing/executor/MavenRuntime.java @@ -19,7 +19,6 @@ import java.util.Map; public class MavenRuntime { - private final MavenLauncher launcher; private final TestProperties properties; @@ -30,6 +29,8 @@ public static class MavenRuntimeBuilder { protected final File mavenHome; + protected final String mavenVersion; + protected final File classworldsConf; protected final List extensions = new ArrayList<>(); @@ -39,6 +40,7 @@ public static class MavenRuntimeBuilder { MavenRuntimeBuilder(File mavenHome, File classworldsConf) { this.properties = new TestProperties(); this.mavenHome = mavenHome; + this.mavenVersion = MavenInstallationUtils.getMavenVersion(mavenHome, classworldsConf); this.classworldsConf = classworldsConf; StringBuilder workspaceState = new StringBuilder(); @@ -47,7 +49,7 @@ public static class MavenRuntimeBuilder { String workspaceResolver = properties.get("workspaceResolver"); if (workspaceState.length() > 0 && isFile(workspaceResolver)) { - if ("3.2.1".equals(MavenInstallationUtils.getMavenVersion(mavenHome, classworldsConf))) { + if ("3.2.1".equals(mavenVersion)) { throw new IllegalArgumentException( "Maven 3.2.1 is not supported, see https://jira.codehaus.org/browse/MNG-5591"); } @@ -72,6 +74,7 @@ private void appendLocation(StringBuilder workspaceState, String location) { MavenRuntimeBuilder(File mavenHome, File classworldsConf, List extensions, List args) { this.properties = new TestProperties(); this.mavenHome = mavenHome; + this.mavenVersion = MavenInstallationUtils.getMavenVersion(mavenHome, classworldsConf); this.classworldsConf = classworldsConf; this.extensions.addAll(extensions); this.args.addAll(args); diff --git a/takari-plugin-testing/src/main/java/io/takari/maven/testing/executor/junit/MavenVersionResolver.java b/takari-plugin-testing/src/main/java/io/takari/maven/testing/executor/junit/MavenVersionResolver.java index 68bd6bf..d5e161e 100644 --- a/takari-plugin-testing/src/main/java/io/takari/maven/testing/executor/junit/MavenVersionResolver.java +++ b/takari-plugin-testing/src/main/java/io/takari/maven/testing/executor/junit/MavenVersionResolver.java @@ -91,15 +91,15 @@ public void resolve(String[] versions) throws Exception { "Cannot test %s plugin release with %s maven", properties.getPluginVersion(), version); error(version, new IllegalStateException(msg)); } - File basdir = new File("target/maven-installation").getCanonicalFile(); - File mavenHome = new File(basdir, "apache-maven-" + version).getCanonicalFile(); + File basedir = new File("target/maven-installation").getCanonicalFile(); + File mavenHome = new File(basedir, "apache-maven-" + version).getCanonicalFile(); if (!mavenHome.isDirectory()) { if (repositories == null) { repositories = getRepositories(properties); } Authenticator defaultAuthenticator = getDefaultAuthenticator(); try { - createMavenInstallation(repositories, version, properties.getLocalRepository(), basdir); + createMavenInstallation(repositories, version, properties.getLocalRepository(), basedir); } catch (Exception e) { error(version, e); } finally {