Hi,
As part of our incremental conversion from Ant to Gradle I need to be able to use Gradle to set some global ant filesets. Setting a property works just fine.
I have tried 2 approaches on the Gradle side:
- ant.references.put(“testxFileset”, basePath.files), but then ant tells me this is not a fileset.
- basePath.addToAntBuilder(project.ant, ‘ant’, FileCollection$AntType.FileSet), but I’m not sure what to put for the nodeName here , ‘ant’ does not work.
Here is my sample code:
Gradle Script:
ant.importBuild 'build.xml'
def FileCollection basePath = files(fileTree(dir: '../tools/ant/lib', include: '*.jar'))
def testProp = "88"
echoValues {
ant.properties.testxProp = testProp //Sets an ant property prior to calling the target.
basePath.addToAntBuilder(project.ant, 'ant', FileCollection$AntType.FileSet)
//ant.references.put("testxFileset", basePath.files)
println "testxProp=" + ant.properties.get("testxProp")
println "testxFileset=" + ant.references.get("testxFileset")
}
Ant script:
<project name="sandbox" basedir=".">
<target name="echoValues">
<echo message="${testxProp}"/>
<foreach target="bar" param="theFile">
<fileset refid="testxFileset"/>
</foreach>
</target>
<target name="bar">
<echo message="${theFile}"/>
</target>
</project>
Any help would be appreciated.
Thanks,
Michael