Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made isRequiredBy compatible with composite gradle builds #460

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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