As section “14.5. Configuring arbitrary objects using an external script” describes you can assign values to objects from scripts.
I’m trying it this way:
def arr = []
apply from: "dependencies.lock", to: arr
println "arr = ${arr}"
where dependencies.lock looks like:
[
"commons-lang:commons-lang:2.5",
"org.apache.commons:commons-lang3:3.0",
"org.springframework:spring-core:3.2.0.RELEASE",
"org.springframework:spring-context:3.2.0.RELEASE",
"org.springframework:spring-webmvc:3.2.0.RELEASE"
]
But this won’t work. The myArr is empty. Note that the example in section 14.5 is slightly different, but I wonder if something like above is possible?
What I want to end up is to do something like:
def myArr = []
apply from: "dependencies.lock", to: arr
configurations.all {
resolutionStrategy.force myArr
}
In this case I could have a clean and simple dependencies.lock file just containing an array.
I was also trying different techniques like:
ResolutionStrategy rs = configurations.compile.resolutionStrategy
apply from: "dependencies.lock", to: rs
this works if dependencies.lock has:
forcedModules = [
"commons-lang:commons-lang:2.5",
"org.apache.commons:commons-lang3:3.0",
"org.springframework:spring-core:3.2.0.RELEASE",
"org.springframework:spring-context:3.2.0.RELEASE",
"org.springframework:spring-webmvc:3.2.0.RELEASE"
]
But this way I cannot use configurations.all as it has no ResolutionStrategy. Maybe I should just loop over all configurations instead.
I’m really spamming this forum with questions at the moment But we are making good progress on or prototype and feeling more and more confident we will be able to use Gradle in the end!