Continuing the discussion from New model confusion :
Was scratching my head today, but cannot figure out why addTasks
never gets called.
@Managed
interface DockerContainer {
void setDockerDir(File location)
File getDockerDir()
}
@Model
void dockerComponents(ModelMap<DockerContainer> components) {
}
@Mutate
void addTasks(ModelMap<Task> tasks, ModelMap<DockerContainer> components) {
/* ... Never gets called */
}
axl
(Andreas Axelsson)
May 30, 2016, 3:48am
2
I don’t use collections in my model, but based on how most of the software component bits seem to work, how about:
@Mutate
void addTasks(ModelMap<Task> tasks, DockerContainer component) {
/* Gets one component for each call */
}
axl
(Andreas Axelsson)
May 30, 2016, 3:54am
3
Hmm, I realize I do have a few methods that take a collection, but they also take a single extension parameter, or, they specify the path of the collection, like this: (Still no @Model collection though)
@Mutate
void doStuff(ModelMap<Task> tasks, ModelMap<MySpecInternal> specs, MyExtension extension) {
/* stuff */
}
@Mutate
void addTasks(@Path("tasks.assemble") Task lifecycle, @Path("binaries") ModelMap<MyBaseBinarySpec> specs) {
/* stuff */
}
1 Like
This is working for me in Gradle 2.13, where every product created gets a generate task. What does your model block look like?
@Managed
interface Product extends Named
{
...
}
class ProductRuleSource extends RuleSource
{
@Model
void products( ModelMap<Product> prods ) {}
@Mutate
void createTasks( ModelMap<Task> tasks, ModelMap<Product> prods )
{
prods.each {
tasks.create( "generate${it.name.capitalize()}" )
}
}
}
apply plugin: ProductRuleSource
model {
products {
prodOne( Product ) {
...
}
}
}
I’d better go and test it with Gradle 2.13 and see if it makes a difference.