Hi Richard

1) Task rules could be one approach.

2) Or, you could dynamically create four tasks. Iterate over a list of 
'parameters' and dynamically create a task for each element. See a sample below 
(the content of the Zip task is not complete and not relevant for this example):

['A', 'B', 'C', 'D'].each { def targetName ->
    tasks.add(name: "zipIt$targetName", type: Zip) {
        baseName = 'jboss-4.0.2-live'
        destinationDir = file("${targetName}.zip")
        from('jboss-4.0.2-master') {
            into 'jboss-4.0.2-live'
        }
    }
}

Additionally, you could add a convenience task to execute all four tasks above. 
You could filter by type, or by a custom matcher like I do in the example below:

task zipAll(dependsOn: tasks.matching { Task task -> 
task.name.startsWith("zipIt")})

Regards, Etienne



On 03.12.2010, at 15:38, richardm wrote:

> 
> Is is possible to call a task in Gradle with different parameters?  I've got
> a zip task which I'd like to call several times.  The project below defines
> a single zip task which uses a properties file to apply filters during the
> zip.  I need to create 4 zip files like this (the only differences are the
> zip names and the properties file used to filter with).  Is it possible to
> do this with one task and call it four times with different parameters?
> 
> project(':jboss') {
> 
>    Properties jboss4LiveProps = new Properties()
>    jboss4LiveProps.load(new
> FileInputStream("$projectDir/property-files/jboss4-live.properties"))
> 
>    dependsOn(':otherProject')
> 
>    filesToDeploy = dir('files_to_deploy')
> 
>    task zipIt(type: Zip, dependsOn: filesToDeploy) {    
>        baseName = 'jboss-4.0.2-live'          
>        destinationDir = file("files_to_deploy")                             
>        from ('jboss-4.0.2-master') {
>            include "**/*.xml", "**/*.bat", "**/*.sh", "**/*properties"        
>     
>            filter(ReplaceTokens, tokens: jboss4LiveProps)
>            into 'jboss-4.0.2-live'
>        }
>        from .....
> 
>    }
> 
>    task build(dependsOn: 'zipIt')
> 
> }
> -- 
> View this message in context: 
> http://gradle.1045684.n5.nabble.com/calling-task-multiple-times-with-different-parameters-tp3290970p3290970.html
> Sent from the gradle-user mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>    http://xircles.codehaus.org/manage_email
> 
> 

Etienne Studer
Senior Software Developer

Canoo Engineering AG
Kirschgartenstrasse 5
CH-4051 Basel

T +41 61 228 94 44
F +41 61 228 94 49

[email protected]
www.canoo.com



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to