Skip to content

Commit

Permalink
Make sure TestMojo resolves test scoped dependencies
Browse files Browse the repository at this point in the history
(cherry picked from commit 25c96c3)
  • Loading branch information
aloubyansky authored and gsmet committed Jan 9, 2023
1 parent 82047ff commit 8d8d644
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
}
Expand Down
7 changes: 7 additions & 0 deletions devtools/maven/src/main/java/io/quarkus/maven/TestMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<DevModeContext>() {
Expand Down

0 comments on commit 8d8d644

Please sign in to comment.