I am working on moving an ant project to gradle project. I have a set of file collection where to be used in as input for several tasks. This is possible in ant with .
<zipfileset id="zipfileset1" src="C:/reporter/servlet/reporter.war">
<include name="WEB-INF/classes/**/*.class"/>
<exclude name="WEB-INF/classes/**/*_jsp*.class"/>
</zipfileset>
<fileset id="fileset1" dir="C:/lib">
<include name="test*.jar"/>
</fileset>
<union id="resources.reports.lib">
<fileset refid="fileset1"/>
<fileset id="fileset2" dir="C:/adaptors/lib">
<include name="com*.jar"/>
</fileset>
<zipfileset refid="zipfileset1"/>
</union>
Is there any method in gradle equivalent to "union" in ant.
There is a working example here
Note that Gradle has tight integration with Ant (see here) so one option is a straight migration from the Ant code. For example:
// NOTE: this uses local dirs instead of Windows paths (e.g. C:\lib)
ant.zipfileset(id:"zipfileset1", src:"c_reporter/servlet/reporter.war") {
include(name:"WEB-INF/classes/**/*.class")
exclude(name:"WEB-INF/classes/**/*_jsp*.class")
}
ant.fileset(id:"fileset1", dir:"c_lib") {
include(name:"test*.jar")
}
ant.union(id:"resources.reports.lib") {
fileset(refid:"fileset1")
fileset(id:"fileset2", dir:"c_adaptors/lib") {
include(name:"com*.jar")
}
zipfileset(refid:"zipfileset1")
}
Per comment, an alternative -- and more Gradle-esque approach -- is: (also illustrated in the link above)
project.ext.zipFiles1 =
zipTree("${projectDir}/c_reporter/servlet/reporter.war").matching {
include 'WEB-INF/classes/**/*.class'
exclude 'WEB-INF/classes/**/*_jsp.class'
}
project.ext.files1 =
fileTree("${projectDir}/c_lib").matching {
include 'test*.jar'
}
project.ext.files2 =
fileTree("${projectDir}/c_adaptors/lib").matching {
include 'com*.jar'
}
project.ext.allFiles =
project.ext.zipFiles1.plus(project.ext.files1)
.plus(project.ext.files2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With