> 1) how to I apply this filter throughout ALL assemble tasks (project
> and subproject). Do I need to call project.allProjects and iterate
> each project, then apply this filter to each assemble task?
Yeah, pretty much.
> 2) the code snippet is in build script form. This code would go
> inside my plugin (a class). I'm not quite sure how to handle this in
> groovy code (trying right now, I'll reply if I make progress)
The build script has some DSL smartness but you're going to call the
same method so it should be very similar, e.g: task foo(type: Bar) {}
in script could be project.task('bar', type: Bar) {} in the plugin
code. Provided you have chosen the right language to develop your
plugin :)
In general you can override existing tasks (like Luke shown) or change
the dependencies of existing tasks if you really need to
(someTask.dependsOn = ['someOther'])
Cheers!
>
> thanks
> phil
>
>
> On Thu, Jul 21, 2011 at 5:55 PM, Luke Daley <[email protected]> wrote:
>>
>> On 22/07/2011, at 9:01 AM, phil swenson wrote:
>>
>>> I am creating some dynamic jar tasks in a custom plugin I'm writing...
>>> My problem is "gradle assemble" calls it. And these custom jar tasks
>>> depend on other processes to be completed before they run. And this
>>> particular task that runs the code below depends on "Assemble". So it
>>> fails if I run assemble and it fails if I run this custom task.....
>>>
>>> Here is the code:
>>>
>>> locales.each {locale ->
>>> Jar jarTask =
>>> project.tasks.add("$BUNDLE_ARTIFACT_TASK_PREFIX[${locale}]",
>>> Jar.class) as Jar
>>> String classifier = locale == "noLocale" ? "" : locale
>>> jarTask.from
>>> "${project.l10nConvention.localizationOutputPath}/$JARS_DIR"
>>> jarTask.destinationDir = new File("${project.buildDir}/libs")
>>> jarTask.baseName = project.name
>>> jarTask.appendix = "l10n"
>>> jarTask.classifier = classifier
>>> jarTask.manifest {
>>> attributes("Bundle-ManifestVersion": '2')
>>> attributes("Bundle-Name": project.name)
>>> attributes("Bundle-SymbolicName":
>>> "${project.symbolicName}.${jarTask.appendix}.${jarTask.classifier}")
>>> attributes("Bundle-Vendor": "myco")
>>> }
>>>
>>> ArchivePublishArtifact jarArchive = new
>>> ArchivePublishArtifact(jarTask)
>>> jarArchive.type = ARCHIVE_TYPE
>>> configuration.addArtifact(jarArchive)
>>> }
>>>
>>> So my question is: how do I prevent this jarTask from being executed
>>> as part of Assemble?
>>
>> So here's the assemble source:
>>
>> https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/groovy/org/gradle/api/plugins/BasePlugin.groovy#L55
>>
>> One quick and dirty way would be:
>>
>> task assemble(overwrite: true) {
>> dependsOn tasks.withType(AbstractArchiveTask).matching {
>> !locales.collect { BUNDLE_ARTIFACT_TASK_PREFIX[it] }.contains(it.name) }
>> }
>>
>> BUT… it would be much better to just express the dependencies of your custom
>> jar tasks properly as a more holistic solution.
>>
>> --
>> Luke Daley
>> Principal Engineer, Gradleware
>> http://gradleware.com
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>> http://xircles.codehaus.org/manage_email
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
--
Szczepan Faber
Principal engineer@gradleware
Lead@mockito
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email