Slackbot
08/31/2022, 9:00 AMVampire
08/31/2022, 10:22 AMtasks.register, it is probably when that plugin tries to add the task when you get the error that the task already exists, because, well, you registered it first.
What you miss is a
pluginManager.withPlugin("plugin that registers the task") {
...
}
around the try to configure the existing task.
Using afterEvaluate is almost always the wrong way.Vampire
08/31/2022, 10:22 AMpluginManager.withPlugin you can apply the plugin explicitly firstVampire
08/31/2022, 10:25 AMVampire
08/31/2022, 10:27 AMVampire
08/31/2022, 10:27 AMplugins { ... } block, then you also have the type-safe accessor for the task and do not need to get the task by String name.Sebastian Schuberth
08/31/2022, 10:48 AMwithPlugin construct. But using
pluginManager.withPlugin("batect-kotlin") {
still gives Task with name 'checkJourneyTestNaming' not found in project ':app'.Sebastian Schuberth
08/31/2022, 10:49 AMbuildSrc would be the next step.Vampire
08/31/2022, 10:55 AMVampire
08/31/2022, 10:58 AMSebastian Schuberth
08/31/2022, 10:58 AMid , or its name used in the create call?Vampire
08/31/2022, 10:58 AMcreate call?
The id that you also use to apply the plugin.Sebastian Schuberth
08/31/2022, 10:58 AMVampire
08/31/2022, 10:59 AMSebastian Schuberth
08/31/2022, 11:00 AMSebastian Schuberth
08/31/2022, 11:00 AMVampire
08/31/2022, 11:03 AMcheckJourneyTestNaming and a task called checkJourneyTestNaming .
The old Groovy script configured the extension.
The task is registered in afterEvaluate which should actually be fixed.
That's the reason you cannot configure the task like you tried.
You could probably do tasks.withType<JourneyTestNamingCheckTask>().matching { it.name == "checkJourneyTestNaming" }.configureEach { ... } that should also work with the task registered in afterEvaluate without using afterEvaluate yourself for the price of realizing all tasks of type JourneyTestNamingCheckTask to evaluate the matching.
But I think configuring the extension like is done in the Groovy variant is the better solution.
And of course fixing afterEvaluate usage in the batect plugin.Vampire
08/31/2022, 11:03 AMSebastian Schuberth
08/31/2022, 12:56 PM