So how should tasks be combined in situations like this? One tasks output should be another tasks input and execution (and even existence) of the second task is logically a configuration of the first task.
I understand that for a “default” task, like the one added by the plugin in the example, the plugin can explicitly create the necessary “subtask” tasks and setup the dependencies. But this won’t allow users to use the task type very easily. Are you saying that it should always be necessary for the user to understand and explicitly declare these subtasks and their dependencies?
An alternative I can think of would be to configure these tasks using a named domain container, and then have the plugin create the actual tasks dynamically for each domain. This seems more complicated to me, though:
‘’’ // In the gradle config jsbuild {
main {
namespace = ‘tutorial.notepad’
source = javascript.source.main.js
} } ‘’’
‘’’ // In the plugin project.afterEvaluate {
project.jsbuild.each { JsBuildExtension ext ->
project.task("${ext.name}.build",type:BuildJsTask) {
namespace = ext.namespace
source = ext.source
}
} } ‘’’
It sounds like you’re saying the latter option would be your preference. My concern here is that for a languages like javascript, there are many possible ways to compile and package from source. NamedDomain containers seem to make sense for source configuration, but it would then be necessary to duplicated much of that configuration for the build task configuration.
In the above example, you’d have something like: ‘’’ // In the gradle config javascript.source {
main.js {
srcDir = javascript.source.main.js
} jsbuild {
main {
namespace = ‘tutorial.notepad’
source = javascript.source.main.js
} } ‘’’ Even though that’s more concise than explicitly configuring multiple build tasks, it somehow seems like it could be confusing? If this is how other plugins are doing things, that makes sense to me, though.