On 16/10/2010, at 1:53 AM, Etienne Studer wrote:

> Hi
> 
> I'm trying to create a zip task in order to zip the sources of all my source 
> sets. How do I achieve this? The following things don't work:
> 
> // without tests
> task zip(type: Zip) {
>    classifier = 'src'
>    from project.sourceSets.main.java.srcDirs

This is the best option for including the main source:

from project.sourceSets.main.allSource

using java.srcDirs won't include any resources, nor any source directories 
which may be added later in the build script, nor any other types of source 
directories added by plugins (eg Groovy, Scala, Antlr, etc).

> }
> 
> // with tests
> task zip(type: Zip) {
>    classifier = 'src'
>    from project.sourceSets

from project.sourceSets*.allSource

or something like this, to split the source into separate directories:

projects.sourceSets { sourceSet ->
    into(sourceSet.name) { from sourceSet.allSource }
}


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz

Reply via email to