From 4602c59fe031bc354358a274c59aa4bf43b45857 Mon Sep 17 00:00:00 2001 From: Guillaume Le Floch Date: Thu, 13 Jan 2022 21:51:49 +0100 Subject: [PATCH] Declare resource directories as application roots for IDE launch --- .../io/quarkus/bootstrap/IDELauncherImpl.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java index 3f90687f6105b..b0390e2bc9124 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java @@ -4,6 +4,7 @@ import io.quarkus.bootstrap.app.CuratedApplication; import io.quarkus.bootstrap.app.QuarkusBootstrap; import io.quarkus.bootstrap.model.ApplicationModel; +import io.quarkus.bootstrap.model.PathsCollection; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver; import io.quarkus.bootstrap.util.BootstrapUtils; @@ -15,6 +16,8 @@ import java.io.Closeable; import java.io.IOException; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; import java.util.Map; /** @@ -45,12 +48,20 @@ public static Closeable launch(Path classesDir, Map context) { final ApplicationModel quarkusModel = BuildToolHelper.enableGradleAppModelForDevMode(classesDir); context.put(BootstrapConstants.SERIALIZED_APP_MODEL, BootstrapUtils.serializeAppModel(quarkusModel, false)); - final Path launchingModulePath = quarkusModel.getApplicationModule().getMainSources().getSourceDirs().iterator() + ArtifactSources mainSources = quarkusModel.getApplicationModule().getMainSources(); + + final Path launchingModulePath = mainSources.getSourceDirs().iterator() .next().getOutputDir(); + List applicationRoots = new ArrayList<>(); + applicationRoots.add(launchingModulePath); + for (SourceDir resourceDir : mainSources.getResourceDirs()) { + applicationRoots.add(resourceDir.getOutputDir()); + } + // Gradle uses a different output directory for classes, we override the one used by the IDE builder.setProjectRoot(launchingModulePath) - .setApplicationRoot(launchingModulePath) + .setApplicationRoot(PathsCollection.from(applicationRoots)) .setTargetDirectory(quarkusModel.getApplicationModule().getBuildDir().toPath()); for (ResolvedDependency dep : quarkusModel.getDependencies()) {