I have a few custom Gradle tasks I've created perform analysis on the build, which I'll make use of when doing certain types changes (e.g. viewing changes in included dependencies as I upgrade library versions). These are tasks for my own benefit, and not something I want committed to source control. Therefore, I ideally want them specified externally to build.gradle
and included in a manner that does not require changing any of the committed build files. Otherwise, the custom tasks will undoubtably be accidentally included in a commit and will need to be backed out later.
To make it concrete, here's a simplified version of a task which prints all compile-time dependencies:
task dependencyList {
doLast {
println "Compile dependencies:"
def selectedDeps = project.configurations.compileClasspath.incoming.resolutionResult.allDependencies.collect { dep ->
"${dep.selected}"
}
selectedDeps.unique().sort().each { println it }
}
}
How can I execute this task against my Gradle build without making any changes to build.groovy
or other files that would normally be committed to source control with the project?