Skip to content

Commit e6354c1

Browse files
authored
Merge pull request #48363 from aloubyansky/quarkusDependenciesBuild-mustRunAfter-jandex
Make quarkusDependenciesBuild run after Jandex tasks, in case they are configured
2 parents 14fca6b + d918163 commit e6354c1

File tree

6 files changed

+28
-23
lines changed

6 files changed

+28
-23
lines changed

devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ private void registerTasks(Project project, QuarkusPluginExtension quarkusExt) {
249249
QuarkusBuildDependencies.class,
250250
task -> {
251251
configureQuarkusBuildTask(project, task, quarkusBuildAppModelTask, serviceProvider);
252-
253252
task.getOutputs().doNotCacheIf("Dependencies are never cached", t -> true);
254253
});
254+
project.afterEvaluate(evaluated -> addDependencyOnJandexIfConfigured(evaluated, quarkusBuildDependencies));
255255

256256
Property<Boolean> cacheLargeArtifacts = quarkusExt.getCacheLargeArtifacts();
257257

@@ -646,7 +646,7 @@ private void visitProjectDep(Project project, Project dep, Set<String> visited)
646646
}
647647

648648
private void setupQuarkusBuildTaskDeps(Project project, Project dep, Set<String> visited) {
649-
if (!visited.add(dep.getGroup() + ":" + dep.getName())) {
649+
if (!visited.add(dep.getPath())) {
650650
return;
651651
}
652652

@@ -663,18 +663,24 @@ private void setupQuarkusBuildTaskDeps(Project project, Project dep, Set<String>
663663
});
664664

665665
getLazyTask(project, QUARKUS_DEV_TASK_NAME).ifPresent(quarkusDev -> {
666-
for (String taskName : new String[] { JavaPlugin.PROCESS_RESOURCES_TASK_NAME,
667-
// This is the task of the 'org.kordamp.gradle.jandex' Gradle plugin
668-
"jandex",
669-
// This is the task of the 'com.github.vlsi.jandex' Gradle plugin
670-
"processJandexIndex" }) {
671-
getLazyTask(dep, taskName).ifPresent(t -> quarkusDev.configure(qd -> qd.dependsOn(t)));
672-
}
666+
getLazyTask(project, JavaPlugin.PROCESS_RESOURCES_TASK_NAME)
667+
.ifPresent(t -> quarkusDev.configure(qd -> qd.dependsOn(t)));
668+
addDependencyOnJandexIfConfigured(dep, quarkusDev);
673669
});
674670

675671
visitProjectDependencies(project, dep, visited);
676672
}
677673

674+
private void addDependencyOnJandexIfConfigured(Project project, TaskProvider<? extends Task> quarkusTask) {
675+
for (String taskName : new String[] {
676+
// This is the task of the 'org.kordamp.gradle.jandex' Gradle plugin
677+
"jandex",
678+
// This is the task of the 'com.github.vlsi.jandex' Gradle plugin
679+
"processJandexIndex" }) {
680+
getLazyTask(project, taskName).ifPresent(t -> quarkusTask.configure(qd -> qd.mustRunAfter(t)));
681+
}
682+
}
683+
678684
protected void visitProjectDependencies(Project project, Project dep, Set<String> visited) {
679685
final Configuration compileConfig = dep.getConfigurations().findByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME);
680686
if (compileConfig != null) {
@@ -689,10 +695,10 @@ protected void visitProjectDependencies(Project project, Project dep, Set<String
689695
.forEach(d -> {
690696
Project depProject = null;
691697

692-
if (d instanceof ProjectDependency) {
693-
depProject = dep.project(((ProjectDependency) d).getPath());
694-
} else if (d instanceof ExternalModuleDependency) {
695-
depProject = ToolingUtils.findIncludedProject(project, (ExternalModuleDependency) d);
698+
if (d instanceof ProjectDependency projectDep) {
699+
depProject = dep.project(projectDep.getPath());
700+
} else if (d instanceof ExternalModuleDependency externalModuleDep) {
701+
depProject = ToolingUtils.findIncludedProject(project, externalModuleDep);
696702
}
697703

698704
if (depProject == null) {
@@ -711,13 +717,9 @@ protected void visitProjectDependencies(Project project, Project dep, Set<String
711717
private void visitLocalProject(Project project, Project localProject, Set<String> visited) {
712718
// local dependency, so we collect also its dependencies
713719
visitProjectDep(project, localProject, visited);
714-
715-
ExtensionDependency<?> extensionDependency = DependencyUtils
716-
.getExtensionInfoOrNull(project, localProject);
717-
718-
if (extensionDependency instanceof ProjectExtensionDependency) {
719-
visitProjectDep(project,
720-
((ProjectExtensionDependency) extensionDependency).getDeploymentModule(), visited);
720+
ExtensionDependency<?> extensionDependency = DependencyUtils.getExtensionInfoOrNull(project, localProject);
721+
if (extensionDependency instanceof ProjectExtensionDependency projectExtDep) {
722+
visitProjectDep(project, projectExtDep.getDeploymentModule(), visited);
721723
}
722724
}
723725

integration-tests/gradle/src/main/resources/jandex-basic-multi-module-project-kordamp/application/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'io.quarkus'
3+
id 'org.kordamp.gradle.jandex' // this plugin is applied to make the dependencies on the Jandex tasks are properly setup and the build doesn't fail
34
}
45

56
dependencies {

integration-tests/gradle/src/main/resources/jandex-basic-multi-module-project-kordamp/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ subprojects {
3939
}
4040

4141
dependencies {
42-
implementation 'io.quarkus:quarkus-resteasy'
42+
implementation 'io.quarkus:quarkus-rest'
4343

4444
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
4545
}

integration-tests/gradle/src/main/resources/jandex-basic-multi-module-project-kordamp/common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
id 'io.quarkus'
33
id 'java-library'
4-
id "org.kordamp.gradle.jandex" version "1.1.0"
4+
id 'org.kordamp.gradle.jandex'
55
}
66

77
dependencies {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
quarkusPlatformArtifactId=quarkus-bom
2-
quarkusPlatformGroupId=io.quarkus
2+
quarkusPlatformGroupId=io.quarkus
3+
kordampJandexVersion=2.1.0

integration-tests/gradle/src/main/resources/jandex-basic-multi-module-project-kordamp/settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pluginManagement {
1212

1313
plugins {
1414
id 'io.quarkus' version "${quarkusPluginVersion}"
15+
id 'org.kordamp.gradle.jandex' version "${kordampJandexVersion}"
1516
}
1617
}
1718

0 commit comments

Comments
 (0)