From 66cd0daa16182b5bd59a9781549f5d04c46228c4 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Mon, 8 Mar 2021 10:39:21 +0100 Subject: [PATCH] Pass the local maven repo path to the tests as maven.repo.local system property and the maven settings as mave.settings property --- build-parent/pom.xml | 6 +++-- .../maven/it/KotlinCreateMavenProjectIT.java | 2 -- integration-tests/maven/pom.xml | 12 --------- .../io/quarkus/maven/it/AddExtensionIT.java | 2 -- .../maven/it/CreateExtensionMojoIT.java | 1 - .../maven/it/CreateJBangProjectMojoIT.java | 2 -- .../it/CreateProjectCodestartMojoIT.java | 2 -- .../quarkus/maven/it/CreateProjectMojoIT.java | 3 +-- .../io/quarkus/maven/it/GenerateConfigIT.java | 2 +- .../io/quarkus/maven/it/ListExtensionsIT.java | 2 -- .../maven/it/ScalaCreateMavenProjectIT.java | 2 -- .../io/quarkus/maven/it/MojoTestBase.java | 27 ++++++++++++++++--- .../maven/it/verifier/RunningInvoker.java | 4 ++- 13 files changed, 33 insertions(+), 34 deletions(-) diff --git a/build-parent/pom.xml b/build-parent/pom.xml index 31ed73ec8df1d..1c8839fbd8004 100644 --- a/build-parent/pom.xml +++ b/build-parent/pom.xml @@ -316,7 +316,8 @@ org.jboss.logmanager.LogManager ${maven.home} - ${settings.localRepository} + ${settings.localRepository} + ${session.request.userSettingsFile.path} ${project.version} ${jacoco.agent.argLine} -Xmx1500m @@ -331,7 +332,8 @@ org.jboss.logmanager.LogManager ${maven.home} - ${settings.localRepository} + ${settings.localRepository} + ${session.request.userSettingsFile.path} ${project.version} diff --git a/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinCreateMavenProjectIT.java b/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinCreateMavenProjectIT.java index a287af51a1778..13f34e386e960 100644 --- a/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinCreateMavenProjectIT.java +++ b/integration-tests/kotlin/src/test/java/io/quarkus/kotlin/maven/it/KotlinCreateMavenProjectIT.java @@ -77,14 +77,12 @@ private InvocationResult setup(Properties params) params.setProperty("platformArtifactId", "quarkus-bom"); params.setProperty("platformVersion", getQuarkusCoreVersion()); - enableDevToolsTestConfig(params); InvocationRequest request = new DefaultInvocationRequest(); request.setBatchMode(true); request.setGoals(Collections.singletonList( getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":create")); request.setProperties(params); - getEnv().forEach(request::addShellEnvironment); File log = new File(testDir, "build-create-" + testDir.getName() + ".log"); PrintStreamLogger logger = new PrintStreamLogger(new PrintStream(new FileOutputStream(log), false, "UTF-8"), InvokerLogger.DEBUG); diff --git a/integration-tests/maven/pom.xml b/integration-tests/maven/pom.xml index 840d608e604a7..b52db2d4a25a3 100644 --- a/integration-tests/maven/pom.xml +++ b/integration-tests/maven/pom.xml @@ -76,11 +76,6 @@ org.apache.maven.plugins maven-surefire-plugin - - - ${project.version} - - @@ -94,11 +89,6 @@ - - - ${project.version} - - @@ -121,8 +111,6 @@ maven-failsafe-plugin - ${project.version} - true diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/AddExtensionIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/AddExtensionIT.java index e2202e8a55430..c0ffe9c5742fe 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/AddExtensionIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/AddExtensionIT.java @@ -139,10 +139,8 @@ private void addExtension(boolean plural, String ext) } else { properties.setProperty("extension", ext); } - enableDevToolsTestConfig(properties); request.setProperties(properties); - getEnv().forEach(request::addShellEnvironment); File log = new File(testDir, "build-add-extension-" + testDir.getName() + ".log"); PrintStreamLogger logger = new PrintStreamLogger(new PrintStream(new FileOutputStream(log), false, "UTF-8"), InvokerLogger.DEBUG); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateExtensionMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateExtensionMojoIT.java index 02bc20d3eb9c6..7fa0339261b7c 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateExtensionMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateExtensionMojoIT.java @@ -115,7 +115,6 @@ private InvocationResult setup(Properties params) request.setDebug(false); request.setShowErrors(true); request.setProperties(params); - getEnv().forEach(request::addShellEnvironment); File log = new File(testDir.getParent(), "build-create-extension-" + testDir.getName() + ".log"); PrintStreamLogger logger = new PrintStreamLogger(new PrintStream(new FileOutputStream(log), false, "UTF-8"), InvokerLogger.DEBUG); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateJBangProjectMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateJBangProjectMojoIT.java index 760dc86d0b2dd..66a91e9038600 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateJBangProjectMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateJBangProjectMojoIT.java @@ -51,9 +51,7 @@ private InvocationResult setup(Properties params) getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":create-jbang")); request.setDebug(false); request.setShowErrors(true); - enableDevToolsTestConfig(params); request.setProperties(params); - getEnv().forEach(request::addShellEnvironment); File log = new File(testDir, "build-create-" + testDir.getName() + ".log"); PrintStreamLogger logger = new PrintStreamLogger(new PrintStream(new FileOutputStream(log), false, "UTF-8"), InvokerLogger.DEBUG); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectCodestartMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectCodestartMojoIT.java index 3748ed2a673da..a5d67deb3cbec 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectCodestartMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectCodestartMojoIT.java @@ -160,10 +160,8 @@ private InvocationResult executeCreate(Properties params) getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":create")); request.setDebug(false); request.setShowErrors(true); - enableDevToolsTestConfig(params); request.setProperties(params); - getEnv().forEach(request::addShellEnvironment); PrintStreamLogger logger = getPrintStreamLogger("create-codestart.log"); invoker.setLogger(logger); return invoker.execute(request); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java index dd73536b451f0..b2863ae12ed2f 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java @@ -439,9 +439,8 @@ private InvocationResult setup(Properties params) getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":create")); request.setDebug(false); request.setShowErrors(true); - enableDevToolsTestConfig(params); request.setProperties(params); - getEnv().forEach(request::addShellEnvironment); + File log = new File(testDir, "build-create-" + testDir.getName() + ".log"); PrintStreamLogger logger = new PrintStreamLogger(new PrintStream(new FileOutputStream(log), false, "UTF-8"), InvokerLogger.DEBUG); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/GenerateConfigIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/GenerateConfigIT.java index af3b7dec40074..68cbc38412a7a 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/GenerateConfigIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/GenerateConfigIT.java @@ -67,7 +67,7 @@ private void generateConfig(String filename) Properties properties = new Properties(); properties.setProperty("file", filename); request.setProperties(properties); - getEnv().forEach(request::addShellEnvironment); + File log = new File(testDir, "build-generate-config-" + testDir.getName() + ".log"); PrintStreamLogger logger = new PrintStreamLogger(new PrintStream(new FileOutputStream(log), false, "UTF-8"), InvokerLogger.DEBUG); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/ListExtensionsIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/ListExtensionsIT.java index 0f684b26134dd..29d5730115545 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/ListExtensionsIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/ListExtensionsIT.java @@ -64,8 +64,6 @@ private List listExtensions() request.setGoals(Collections.singletonList( getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":list-extensions")); - getEnv().forEach(request::addShellEnvironment); - enableDevToolsTestConfig(request); File outputLog = new File(testDir, "output.log"); InvocationOutputHandler outputHandler = new PrintStreamHandler( diff --git a/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaCreateMavenProjectIT.java b/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaCreateMavenProjectIT.java index 895636aa9c82c..cccfdf91eb7b2 100644 --- a/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaCreateMavenProjectIT.java +++ b/integration-tests/scala/src/test/java/io/quarkus/scala/maven/it/ScalaCreateMavenProjectIT.java @@ -84,14 +84,12 @@ private InvocationResult setup(Properties params) } params.setProperty("platformArtifactId", getBomArtifactId()); params.setProperty("platformVersion", getQuarkusCoreVersion()); - enableDevToolsTestConfig(params); InvocationRequest request = new DefaultInvocationRequest(); request.setBatchMode(true); request.setGoals(Collections.singletonList( getMavenPluginGroupId() + ":" + getMavenPluginArtifactId() + ":" + getMavenPluginVersion() + ":create")); request.setProperties(params); - getEnv().forEach(request::addShellEnvironment); File log = new File(testDir, "build-create-" + testDir.getName() + ".log"); final PrintStreamLogger logger = new PrintStreamLogger(new PrintStream(new FileOutputStream(log), false, "UTF-8"), InvokerLogger.INFO); diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java index 19edbdb96387f..e869a9f638866 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/MojoTestBase.java @@ -23,7 +23,9 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.shared.invoker.DefaultInvoker; import org.apache.maven.shared.invoker.InvocationRequest; +import org.apache.maven.shared.invoker.InvocationResult; import org.apache.maven.shared.invoker.Invoker; +import org.apache.maven.shared.invoker.MavenInvocationException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import io.quarkus.devtools.test.RegistryClientTestHelper; @@ -31,10 +33,19 @@ public class MojoTestBase { - public static Invoker initInvoker(File root) { - Invoker invoker = new DefaultInvoker(); + public Invoker initInvoker(File root) { + Invoker invoker = new DefaultInvoker() { + @Override + public InvocationResult execute(InvocationRequest request) + throws MavenInvocationException { + passUserSettings(request); + getEnv().forEach(request::addShellEnvironment); + enableDevToolsTestConfig(request); + return super.execute(request); + } + }; invoker.setWorkingDirectory(root); - String repo = System.getProperty("maven.repo"); + String repo = System.getProperty("maven.repo.local"); if (repo == null) { repo = new File(System.getProperty("user.home"), ".m2/repository").getAbsolutePath(); } @@ -42,6 +53,16 @@ public static Invoker initInvoker(File root) { return invoker; } + public static void passUserSettings(InvocationRequest request) { + final String mvnSettings = System.getProperty("maven.settings"); + if (mvnSettings != null) { + final File settingsFile = new File(mvnSettings); + if (settingsFile.exists()) { + request.setUserSettingsFile(settingsFile); + } + } + } + public static File initEmptyProject(String name) { File tc = new File("target/test-classes/" + name); if (tc.isDirectory()) { diff --git a/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java b/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java index 93a10d92bad24..5fbd2dba9c8cd 100644 --- a/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java +++ b/test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/RunningInvoker.java @@ -20,6 +20,7 @@ import org.apache.maven.shared.invoker.PrintStreamHandler; import org.apache.maven.shared.invoker.PrintStreamLogger; +import io.quarkus.maven.it.MojoTestBase; import io.quarkus.test.devmode.util.DevModeTestUtils; /** @@ -37,7 +38,7 @@ public class RunningInvoker extends MavenProcessInvoker { public RunningInvoker(File basedir, boolean debug) { this.debug = debug; setWorkingDirectory(basedir); - String repo = System.getProperty("maven.repo"); + String repo = System.getProperty("maven.repo.local"); if (repo == null) { repo = new File(System.getProperty("user.home"), ".m2/repository").getAbsolutePath(); } @@ -130,6 +131,7 @@ public MavenProcessInvocationResult execute(List goals, Map