user1470220
user1470220

Reputation: 123

Gradle Task - Multiple execution with different PID

I am using Gradle and Groovy to work on the problem. Gradle task is calling a groovy method, which returns the GPATH Result of all site elements, after parsing an xml file. The xml file looks like below:

<?xml version="1.0" encoding="iso-8859-1"?>
<sites>
    <site name="OctUK">
        <property name="warName">OctUKbuild-Deployable</property>
    </site>
    <site name="GbsJP">
        <property name="warName">GbsJPbuild-Deployable</property>
    </site>
</sites>

The Gradle task reads the GPathResult through each method and executes the below ant task:

ant.unzip(src:sourceFile, dest:destFile)

Code:

siteNavigator.findSite().each{
    def siteWarName = it.property.findAll{[email protected]()}
    def destFile="${project.Release_Path}/${project.POSReleaseID}/${siteWarName}- ${project.Version_ID}-${project.env}-${project.appGroup}-exp"
    ant.unzip(src:sourceFile, dest:destFile)
}

The source file is a war file, which needs to be unzipped with name retrieved after parsing the XML file.

It is at the moment a sequential activity.

Is it possible to make it parallel, for e.g. a new ant task will be fired for each element in the GPathResult, so that the ant tasks are parallel.

Upvotes: 0

Views: 198

Answers (1)

tim_yates
tim_yates

Reputation: 171164

Not sure if it will work, but have you tried:

ant.parallel {
    siteNavigator.findSite().each {
        def destFile = "${project.Release_Path}/${project.POSReleaseID}/${it.@name}- ${project.Version_ID}-${project.env}-${project.appGroup}-exp"
        ant.unzip( src:sourceFile, dest:destFile )
    }
}

Upvotes: 2

Related Questions