From 8d8d6449389e9bee950acd67732b9068be472766 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Fri, 6 Jan 2023 23:24:50 +0100 Subject: [PATCH] Make sure TestMojo resolves test scoped dependencies (cherry picked from commit 25c96c3fd17caa890afeac936e4aaa7a18e0d285) --- .../src/main/java/io/quarkus/maven/DevMojo.java | 12 +++++++++++- .../src/main/java/io/quarkus/maven/TestMojo.java | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java index aa3ef463c7f52..3e10e02d71243 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -382,6 +382,15 @@ public class DevMojo extends AbstractMojo { private Pty pty; private boolean windowsColorSupport; + /** + * Indicates for which launch mode the dependencies should be resolved. + * + * @return launch mode for which the dependencies should be resolved + */ + protected LaunchMode getLaunchModeClasspath() { + return LaunchMode.DEVELOPMENT; + } + @Override public void setLog(Log log) { super.setLog(log); @@ -1089,7 +1098,7 @@ private QuarkusDevModeLauncher newLauncher(Boolean debugPortOk) throws Exception final Path appModelLocation = resolveSerializedModelLocation(); ApplicationModel appModel = bootstrapProvider - .getResolvedApplicationModel(QuarkusBootstrapProvider.getProjectId(project), LaunchMode.DEVELOPMENT); + .getResolvedApplicationModel(QuarkusBootstrapProvider.getProjectId(project), getLaunchModeClasspath()); if (appModel != null) { bootstrapProvider.close(); } else { @@ -1118,6 +1127,7 @@ private QuarkusDevModeLauncher newLauncher(Boolean debugPortOk) throws Exception final BootstrapMavenContext mvnCtx = new BootstrapMavenContext(mvnConfig); appModel = new BootstrapAppModelResolver(new MavenArtifactResolver(mvnCtx)) .setDevMode(true) + .setTest(LaunchMode.TEST.equals(getLaunchModeClasspath())) .setCollectReloadableDependencies(!noDeps) .resolveModel(mvnCtx.getCurrentProject().getAppArtifact()); } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/TestMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/TestMojo.java index a8e3008b568ec..bfbf3eff00656 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/TestMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/TestMojo.java @@ -9,12 +9,19 @@ import io.quarkus.bootstrap.app.QuarkusBootstrap; import io.quarkus.deployment.dev.DevModeContext; import io.quarkus.deployment.dev.IsolatedTestModeMain; +import io.quarkus.runtime.LaunchMode; /** * The test mojo, that starts continuous testing outside of dev mode */ @Mojo(name = "test", defaultPhase = LifecyclePhase.PREPARE_PACKAGE, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) public class TestMojo extends DevMojo { + + @Override + protected LaunchMode getLaunchModeClasspath() { + return LaunchMode.TEST; + } + @Override protected void modifyDevModeContext(MavenDevModeLauncher.Builder builder) { builder.entryPointCustomizer(new Consumer() {