How should a Zip task source be specified?

I want to collect the jars from my subprojects into a zip file. I can generate a file with the right contents, but I can’t seem to control the name (it’s always “.zip”). This is happening when I don’t apply any plugin.

def target = file(“collection.zip”)

task jar(dependsOn: subprojects.collect {":blush:it.name:jar"}, type: Zip, baseName: target) {

from {

subprojects.collect {

it.tasks.jar.archivePath

}

}

}

The result is a file that contains the jars I want, but has the name ‘.zip’ instead of ‘collection.zip’

Not sure what exactly is going on here, but ‘baseName’ should be a String (not a File), and it shouldn’t contain the extension part. As usual, the DSL reference has the details.

Yeah, I’ve been trying properties and methods that look like they would set the output file (e.g. outputs.file). The -d option for gradle doesn’t say much about how the tasks are configured. Is there a method that would print the configuration of a task?

I can’t see any difference in the behavior if the code is

def target = “collection”

task jar(dependsOn: subprojects.collect {":blush:it.name:jar"}, type: Zip, baseName: target) {

from {

subprojects.collect {

it.tasks.jar.archivePath

}

}

}

Providing a string with no extension for baseName still produces a file named .zip (containing the desired jars).

Is there a method that would print the configuration of a task?

No there isn’t. You can add some 'println’s though.

Providing a string with no extension for baseName still produces a file named .zip

The ‘baseName’ has to go into the configuration block (‘task jar(…) { baseName = … }’). Only so-called “creation options” (like ‘type’ and ‘dependsOn’) that are common to all tasks can be provided as a named parameter. For more information, see the relevant section in the DSL reference. (Forum messed up the link, but look for Project.task.)

Here’s a gradle.build that you can try. Just copy it to ‘build.gradle’ in a folder that doesn’t have too much in it(!) and then type ‘gradle zip’.

def target = “collection”

task zip(type: Zip, baseName: target) {

from {

file “.”

}

}

How is the zip file name assigned (in rc-3)?

See my previous reply.

Thanks very much for the clarification! I just ready through the Task and Project entries and I still don’t see where the distinction is made between creation properties and configuration properties. I do see how the task parameters are available to the Task - it would be cool if it would warn if it sees something that’s not handled.

Search for “creation options” on http://gradle.org/docs/current/dsl/org.gradle.api.Project.html will immediately find it.