I’d like to do some “work” in a task which adds dependencies to a configuration. I therefore want the task to run every time the configuration is resolved
Consider the following:
configurations {
myConfig
}
task addToMyConfig {
doLast {
println "Doing some work"
dependencies {
myConfig 'log4j:log4j:1.2.17'
}
}
}
task useMyConfig {
doLast {
println "myConfig = $configurations.myConfig.files"
}
}
How do I force addToMyConfig
to run every time myConfig
is resolved? Eg useMyConfig
should ultimately depend on addToMyConfig
** Note ** I do not want to explicitly do
useMyConfig.dependsOn addToMyConfig
Because I don’t know all the tasks which use myConfig
. I’d like something like
configurations.myConfig.builtBy addToMyConfig