I'm not sure it's possible to do it the "holistic" way in my situation. My jar tasks depend on other assemble jar tasks being executed first, and has other dependencies as well. So I end up in a situation where assemble wants my jar tasks to execute but my jar tasks depend on assemble to finish and needs a couple other tasks to execute. It's kind of hairy.
I have two questions about your code snippet. 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? 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) 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
