diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java b/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java index 7dd87f0b30067..0df3bc9b557df 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java @@ -47,7 +47,6 @@ import io.quarkus.bootstrap.BootstrapConstants; import io.quarkus.bootstrap.model.AppArtifactKey; -import io.quarkus.bootstrap.resolver.QuarkusGradleModelFactory; import io.quarkus.bootstrap.resolver.model.ArtifactCoords; import io.quarkus.bootstrap.resolver.model.Dependency; import io.quarkus.bootstrap.resolver.model.ModelParameter; @@ -68,6 +67,9 @@ public class QuarkusModelBuilder implements ParameterizedToolingModelBuilder { + private static final String MAIN_RESOURCES_OUTPUT = "build/resources/main"; + private static final String CLASSES_OUTPUT = "build/classes"; + private static Configuration classpathConfig(Project project, LaunchMode mode) { if (LaunchMode.TEST.equals(mode)) { return project.getConfigurations().getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME); @@ -339,7 +341,7 @@ private void collectDependencies(ResolvedConfiguration configuration, a.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) { IncludedBuild includedBuild = includedBuild(project, a.getName()); if (includedBuild != null) { - addSubstitutedProject(dep, includedBuild.getProjectDir(), mode); + addSubstitutedProject(dep, includedBuild.getProjectDir()); } else { Project projectDep = project.getRootProject() .findProject(((ProjectComponentIdentifier) a.getId().getComponentIdentifier()).getProjectPath()); @@ -413,13 +415,25 @@ private void addDevModePaths(final DependencyImpl dep, ResolvedArtifact a, Proje } } - private void addSubstitutedProject(final DependencyImpl dep, File projectFile, LaunchMode mode) { - final QuarkusModel quarkusModel = QuarkusGradleModelFactory.create(projectFile, mode.name()); - final io.quarkus.bootstrap.resolver.model.SourceSet moduleOutput = quarkusModel.getWorkspace().getMainModule() - .getSourceSet(); - dep.addPath(moduleOutput.getResourceDirectory()); - for (File sourceDirectory : moduleOutput.getSourceDirectories()) { - dep.addPath(sourceDirectory); + private void addSubstitutedProject(final DependencyImpl dep, File projectFile) { + File mainResourceDirectory = new File(projectFile, MAIN_RESOURCES_OUTPUT); + if (mainResourceDirectory.exists()) { + dep.addPath(mainResourceDirectory); + } + File classesOutput = new File(projectFile, CLASSES_OUTPUT); + File[] languageDirectories = classesOutput.listFiles(); + if (languageDirectories == null) { + throw new GradleException( + "The project does not contain a class output directory. " + classesOutput.getPath() + " must exist."); + } + for (File languageDirectory : languageDirectories) { + if (languageDirectory.isDirectory()) { + for (File sourceSet : languageDirectory.listFiles()) { + if (sourceSet.isDirectory() && sourceSet.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME)) { + dep.addPath(sourceSet); + } + } + } } } diff --git a/integration-tests/gradle/src/test/resources/multi-module-included-build/external-library/build.gradle b/integration-tests/gradle/src/test/resources/multi-module-included-build/external-library/build.gradle index 47e70bd7a8757..4cce1a80df2bd 100644 --- a/integration-tests/gradle/src/test/resources/multi-module-included-build/external-library/build.gradle +++ b/integration-tests/gradle/src/test/resources/multi-module-included-build/external-library/build.gradle @@ -1,7 +1,5 @@ plugins { id 'java' - id 'io.quarkus' - id "org.kordamp.gradle.jandex" version '0.6.0' } repositories {