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