Slackbot
06/13/2022, 6:27 AMrekire
06/13/2022, 6:31 AMdeepy
06/13/2022, 7:58 AMVampire
06/13/2022, 8:05 AMRyan Schmitt
06/13/2022, 6:08 PMand the plugin wires their properties together and sets default valueWhat's the idiomatic way to set the default value for the fields of the task? Constructor, setters, property
convention
?Vampire
06/13/2022, 6:12 PMconvention
from within the plugin.
The idiomatic way is that the extensions and tasks are as unopinionated as possible and the plugin registers extensions and tasks and adds opinion to them in form of wiring extensions and tasks together and setting default values.Ryan Schmitt
06/13/2022, 6:52 PMVampire
06/13/2022, 8:29 PMVampire
06/13/2022, 8:29 PMRyan Schmitt
06/13/2022, 8:50 PMVampire
06/13/2022, 8:52 PMRyan Schmitt
06/13/2022, 8:58 PMJavaExec
and its constructor sets default values exactly as I would expect:
javaExecSpec = objectFactory.newInstance(DefaultJavaExecSpec.class);
javaExecSpec.getMainClass().convention(
getMainClass().orElse(
Providers.changing(
// go through 'main' to keep this compatible with existing convention mappings
() -> DeprecationLogger.whileDisabled(this::getMain)
)
)
);
javaExecSpec.getMainModule().convention(mainModule);
javaExecSpec.getModularity().getInferModulePath().convention(modularity.getInferModulePath());
The reason this makes sense to me is because it appears to be idiomatic for build scripts to register/create a given task class pretty much directly, not by invoking some plugin-provided factory method that sets defaultsVampire
06/13/2022, 9:01 PMVampire
06/13/2022, 9:03 PMRyan Schmitt
06/13/2022, 9:03 PMVampire
06/13/2022, 9:21 PM