In the following sample code Both thing1
and thing2
are mutated, although only thing2
is referenced. Why is this happening?
class testPlugin extends RuleSource {
@Model
void things(ModelMap<Thing> things) {}
@Mutate
void mutateThings(ModelMap<Thing> things) {
things.all {
println "**** Mutating Thing: ${name}"
value = 'Plugin Mutated Value'
}
}
}
@Managed
interface Thing extends Named {
String getValue()
void setValue(String value)
}
apply plugin: testPlugin
model {
things {
thing1(Thing) {
value = 'DSL Created Value'
}
thing2(Thing) {
value = 'DSL Created Value'
}
}
}
model {
tasks {
print_stuff(Task) {
if (false) {
println "!!!! This code block should never be run!"
println $.things.thing1.value
println ""
} else {
println "++++ Task Configuration: Defaults Value : ${$.things.thing2.value}"
println ""
}
}
}
}
Output:
**** Mutating Thing: thing1
**** Mutating Thing: thing2
++++ Task Configuration: Defaults Value : Plugin Mutated Value