I know you aren't meant to reference the rootProje...
# community-support
r
I know you aren't meant to reference the rootProject's tasks in a convention plugin... what's the right way to do this?
Copy code
rootProject.tasks.named("dependencies") {
  dependsOn(tasks.named("dependencies"))
}
j
That will break project isolation, I think the answer is, you shouldn’t do that in any way
if you want to run the dependencies task for all projects, just use
Copy code
./gradlew dependencies
instead of
Copy code
./gradlew :dependencies
e
no, unfortunately
dependencies
doesn't work like other task names and is hard-coded to only run in the current subproject
you can create your own task instead,
Copy code
tasks.register("allDependencies") {
    allprojects { dependsOn("$path:dependencies") }
}
r
Nice, thanks... is there any way to enforce an ordering? I'm trying to get a nice diff output to see what dependencies are changing over time, but it's reordering the projects in the output as the deps change, so it's not really usable.
j
If you create a custom task per project, wouldn't it fix it too? So you don't need to depends on other project tasks
Copy code
allprojects {
    tasks.register("getDependencies) {
        dependsOn("$path:dependencies")
    }
}
I'm trying to get a nice diff output to see what dependencies are changing over time, but it's reordering the projects in the output as the deps change, so it's not really usable.
Are you interested on the transitive dependencies too?
I don't know if using lock files can help with this as I haven't used them before, but checking the diff between two lock files maybe?
e
apply the project-report plugin and use its file-based output instead of trying to parse gradle stdout
r
apply the project-report plugin and use its file-based output instead of trying to parse gradle stdout
Nice, thanks
Are you interested on the transitive dependencies too?
Yes, it's the result of using
module { replacedBy }
and things like that that I want to understand.
v
In the solutions above, better replace
allprojects { ... }
by
allprojects.forEach { ... }
. Otherwise you do cross-project configuration through cross-project configuration instead of just using a plain loop.