I'm making some progress on this. Initially, I think my plugin is going to
have these tasks:
build
clean
cleanAll
combineJavascript
compileJavascript
compileTestJavascript
distJavascript
docJavascript
filterJavascript
minifyJavascript
testJavascript
I have some questions though. First, my 'compileJavascript' task is probably
just going to be a meta-task which just depends on, or calls the
'combineJavascript', and 'filterJavascript' tasks. I've created the latter 2
to extend SourceTask, but I'm not sure how to hook them up with a
JavascriptPluginConvention object. Can someone please explain to me how I
can make use of a convention, and have it set the source, includes,
excludes, etc.. in a SourceTask? Also, if I have the compile task simply
depends on, or call the combine and filter tasks, can I have 1 configuration
for those tasks which or should I have individual ones for each? Eg. it
doesn't make sense to have a "filterSourceDir", and "combineSourceDir". I'd
rather just have the user supply/set 1 sourceDir and just use that in both
tasks. I'm thinking this should be part of the convention, but again, not
sure how to hook the convention up with extended tasks.
Would I do something kind of like:
[code lang=groovy]
class JavascriptPlugin implements Plugin<Project> {
void apply(Project project) {
...
project.task('combineJavascript', type: Source) << {
super.source = project.convention.plugins.javascript.srcDir
super.excludes = project.convention.plugins.javascript.srcExcludes
super.execute()
}
...
}
}
[/code]
Also, if I want the doc, minify, and test tasks to execute some external
process what's the appropriate way to handle this? Is it possible for
plugins to define dependencies on external jars? Eg. There is a Google
"Closure Compiler" jar file which I could download then use via command line
on the user's sources.
Or is it better to do a check for the existence of the libraries on the
filesystem and print an error to users if those libraries are not installed?
Lastly, and this is more from a usability standpoint, I noticed that when I
have a task that is a dependency of another task, the first task doesn't
show up with I do a 'gradle -t'. Is there a way to see ALL available tasks
for a build script?
Eg.
project.task('clean') << {}
project.task('cleanAll', dependsOn: 'clean') << {}
If I type: 'gradle -t' I only see 'cleanAll' displayed, 'clean' is not
there. Calling 'gradle clean' still works, it's just that the task isn't
printing out.
Is this the correct behavior?
Thanks for any help,
Eric