Hi, In a custom plugin, I create tasks in the plugin apply method like this.
@Override
void apply( final Project project )
{
project.repositories.jcenter()
project.extensions.create('foo', ...)
// need to have extensions read
project.afterEvaluate {
if (project.foo.enable) {
project.tasks.create('foo', FooTask.class)
}
}
}
Now I want to write unit tests that make sure that this works as expected.
Project project = ProjectBuilder.builder().build()
project.apply plugin: 'fooPlugin'
assert project.tasks.foo ...
This approach does not work, because the afterEvaluate closure was not executed. How can i cause that?
I want to do it like that so that users may choose to use the plugin but not necessarily use all tasks. If there is something generally wrong with my approach tell me so.