I have a task ```tasks.create(name: 'dist', depend...
# community-support
m
I have a task
Copy code
tasks.create(name: 'dist', dependsOn:  subprojects.publishInternal) {
Often execute "./gradlew dist". Sometimes execute "./gradlew clean dist". The latter works fine until setting "org.gradle.parallel=true". What is the correct way to say dist must execute after clean if and only if clean is being executed?
r
Copy code
tasks.create(name: 'dist', dependsOn:  subprojects.publishInternal) {
    mustRunAfter 'clean'
}
should be good enough
m
Thank you. Passed the info along. Colleague testing.
v
Besides that you should not reach into another projects model, assuming that
subprojects.publishInternal
gets some task from the subprojects or similar. That is almost as bad as doing cross-project configuration. And also you should practically never use
tasks.create
as you then do not leverage task-configuration avoidance, but
tasks.register
. And the
mustRunAfter
will not really help either. Because you define that
dist
in that project must run after
clean
in that project. But you do not say anything about the tasks that actually are your problem. Tbh, this question makes me feel like you should do a major overhaul of your build logic. 🙂
m
This is a project with over 200 build.gradle files. It took a lifetime to move the project from 6.0.1 to 8.11. None of this was originated by me. And not seeing anyone that looks dumb enough to go overhaul it ... no matter how good the idea sounds.
v
Well, you should :-) Latest when you want to use isolated projects to cut down configuration time to a sane value you will have to. :-) Also, if you have 200 build scripts, changes are high that you want them to follow some conventions, so must of them should only apply a convention plugin or two and declare some dependencies. Also makes it much more maintainable. :-)
🤷‍♂️