I’m playing with the new model and am trying make check depend on a custom task that runs tests. I have a method (createTasks) thats annotated with @BinaryTasks and it currently adds 7 tasks that build depends on. How do I define a task that check depends on using the new model?
You’ll do this with a @Mutate
rule.
@Mutate
public void addVerificaitonTask(ModelMap<Task> tasks) {
Task myTask = tasks.create("mytask");
tasks.getByName("check").dependsOn(myTask);
}
Thanks for the info. With the new model, should the check tasks be created with the BinaryTasks or make them in an @Mutate method?
The @BinaryTasks
annotation should only be used when the Binary
is an input to the task. If the task you are creating is independent of any binary then I’d say use a @Mutate
rule instead. Really, you can think of @BinaryTasks
as simply a @Mutate
rule that is executed for every Binary
.
Hi @mark_vieira,
ModelMap.create has no return value. Is there a recommended approach apart from calling tasks.get/getByName after calling tasks.create?
@Mutate
public void addVerificationTask(ModelMap<Task> tasks) {
tasks.create("mytask")
tasks.getByName("check").dependsOn(tasks.getByName("mytask"))
}
The dependsOn()
method will also accept a String
.
tasks.getByName('check').dependsOn('mytask')