Hi Eitan, long time! :)
Just wanted to point out that another option is to define the copyspec separately and have individual tasks for each zip along with a "grouping task" that defines deps on the separate tasks. This is exactly what I do to build the Hibernate release bundles. I can point you to the build or copy in snippets if this approach interests you. On Apr 13, 2011 12:11 PM, "Eitan Suez" <[email protected]> wrote: > hello, > > i'm a gradle newb. first of all i'd like to say thank you for gradle. > > i'm trying to write a task that creates a set of zip files, one per > environment. something like this: > > task packageEnvironments { > description = "Package environment-specific artifacts." > > doLast { > ['branch', 'stage', 'production', 'released'].each { envName -> > println "Packaging runtime environment: ${envName}" > zip { > appendix = envName > into "catalina/${envName}" > from "env/webapp/${envName}/catalina" > into('lib') { > from configurations.deploy2CatalinaLib > } > } > } > } > } > > except that, unlike the project.copy() action, there's no > project.zip() action. i sure would like one. > further, i can't even figure out *how* to do this in gradle without > a zip action. > so far, i'm trying to coerce a task as an action like this: > > task packageEnvironments { > description = "Package environment-specific artifacts." > > doLast { > task zipIt(type: Zip) > ['branch', 'stage', 'production', 'released'].each { envName -> > println "Packaging runtime environment: ${envName}" > zipIt.configure { > appendix = envName > into "catalina/${envName}" > from "env/webapp/${envName}/catalina" > into('lib') { > from configurations.deploy2CatalinaLib > } > } > zipIt.execute() > } > } > } > > and it doesn't work. it produces the first zip file, but is a no-op > for the remainder > (perhaps because the inputs/outputs have already been set and perhaps are > immutable and so the next time around it figures the task is > perhaps up to date?). > > my experience *so far* with gradle is wonderful, with this one exception. > > the main disconnect i have is wanting to compose tasks, > wanting to invoke a task or think of a task as a function or something > one can parameterize. but can't. perhaps i shouldn't and that's fine. > > but sometimes there are all these tasks that one just wants to execute > and can't because they're not executable like functions are. > > perhaps what i'm asking for is action versions of the various tasks > that gradle exposes? i.e. a copy action (we have), a zip action (is > there such > a thing?), an exec action (?).. > > often i find myself falling back to using an antbuilder task even when > a gradle equivalent exists because i can treat an ant task as an action, > something i can invoke with its configurations as arguments. i.e. i > often cannot > figure out how to use the gradle equivalent properly. > > anyhow, thanks in advance for any help figuring out how to get this 'zip in > a for loop' task working. > > / eitan > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > >
