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

isRequiredBy resolves dependencies at configuration time #263

Closed
jdai8 opened this issue Oct 5, 2020 · 1 comment · Fixed by #264
Closed

isRequiredBy resolves dependencies at configuration time #263

jdai8 opened this issue Oct 5, 2020 · 1 comment · Fixed by #264

Comments

@jdai8
Copy link
Contributor

jdai8 commented Oct 5, 2020

This call to TaskDependency.getDependencies()causes dependencies to be resolved at configuration time. This slows down builds and prevents other plugins from mutating the configuration (e.g. adding attributes) before it gets resolved.

For example:

dockerCompose {
  isRequiredBy(run)
}

will resolve the runtimeClasspath configuration.

Potential solution

The intention is to run the up task after things have finished compiling right?

Simply wrapping in a taskGraph.whenReady might work:

task.dependsOn upTask
task.finalizedBy downTask
project.taskGraph.whenReady {
    task.getTaskDependencies().getDependencies(task)
                .findAll { Task.class.isAssignableFrom(it.class) && ((Task) it).name.toLowerCase().contains('classes') }
                .each { dep ->
                    if (fromConfigure) {
                        upTask.get().shouldRunAfter dep
                    } else {
                        upTask.configure { it.shouldRunAfter dep }
                    }
       }
}

I'm happy to put up a PR if this seems like the right solution.

@augi
Copy link
Member

augi commented Oct 5, 2020

Hello, thank you for reporting this issue! Feel free to prepare a PR containing this improvement. I'm just not sure if it is possible to use shouldRunAfter from whenReady (just because I don't have experience with it). If it works, then perfect 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants