Skip to content

Commit

Permalink
feat: isRequiredBy made compatible with composite Gradle builds (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbassett authored Oct 10, 2024
1 parent 1ed177e commit ccd287f
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,29 @@ class TasksConfigurator {
task.dependsOn upTask
task.finalizedBy downTask
if (fromConfigure) {
upTask.get().shouldRunAfter task.taskDependencies
upTask.get().shouldRunAfter getTaskDependencies(task)
} else {
upTask.configure { it.shouldRunAfter task.taskDependencies }
upTask.configure { it.shouldRunAfter getTaskDependencies(task) }
}
if (task instanceof ProcessForkOptions) task.doFirst { composeSettings.exposeAsEnvironment(task as ProcessForkOptions) }
if (task instanceof JavaForkOptions) task.doFirst { composeSettings.exposeAsSystemProperties(task as JavaForkOptions) }
}

private Object getTaskDependencies(Task task) {
def includedBuilds = task.project.gradle.includedBuilds
if (includedBuilds.isEmpty()) {
return task.taskDependencies
} else {
// Ignore any task dependencies from a composite/included build to avoid the
// "Cannot use shouldRunAfter to reference tasks from another build" error introduced in Gradle 8
def includedBuildProjectNames = includedBuilds.collect { it.name }.toSet()
return task.taskDependencies.getDependencies(null).findAll { dependency ->
// use rootProject.name in case the task is from a multi-module composite build
!includedBuildProjectNames.contains(dependency.project.rootProject.name)
}
}
}

@PackageScope
Map<String, ServiceInfo> getServicesInfos() {
upTask.get().servicesInfos
Expand Down

0 comments on commit ccd287f

Please sign in to comment.