Ant script: Prevent duplication of JAR in javac-classpath war-lib -
i have ant script , have lot of duplicated path same set jar files. there many double wording in classpath , in war element.
<path id="my.classpath"> <pathelement location="foldera/subfoldera/1.0/a.jar"/> <pathelement location="folderc/subfolderb/1.0/b.jar"/> <pathelement location="folderf/subfolderz/2.0/z.jar"/> <pathelement location="compile/subfolderx/1.0/onlyforjavac.jar"/> </path> .... <javac ...> <classpath refid="my.classpath" /> </javac> .... <war ...> <lib file="foldera/subfoldera/1.0/a.jar"/> <lib file="folderc/subfolderb/1.0/b.jar"/> <lib file="folderf/subfolderz/2.0/z.jar"/> <lib file="morefolderf/subfolderz/2.0/additionfile.jar"/> <lib file="morefolderf/subfolderz/2.0/additionruntimefile.jar"/> </war>
i want summary them 1 list easier keep update.
but blocked have no idea how share path-like-structure fileset-like-structure.
since ant 1.8.0 there new resource collection - mappedresources
can used in place of war
task lib
element.
so, task might (pretty straight docs):
<war ... > <mappedresources> <restrict> <path refid="my.classpath"/> <type type="file"/> </restrict> <chainedmapper> <flattenmapper/> <globmapper from="*" to="web-inf/lib/*"/> </chainedmapper> </mappedresources> </war>
this feature added resolve long-standing feature request make task flatten jars when deploying web-inf/lib
.
previous answer:
although can't convert path fileset vanilla ant, can go other way. 1 option define jars in fileset, , derive path it. perhaps:
<fileset id="my.fileset" dir="${basedir}"> <include name="foldera/subfoldera/1.0/a.jar"/> <include name="folderc/subfolderb/1.0/b.jar"/> <include name="folderf/subfolderz/2.0/z.jar"/> <include name="morefolderf/subfolderz/2.0/additionfile.jar"/> <include name="morefolderf/subfolderz/2.0/additionruntimefile.jar"/> </fileset> <path id="my.classpath"> <fileset refid="my.fileset" /> </path> <!-- javac stays same --> <war ...> <lib refid="my.fileset" /> </war>
another possibility use ant-contrib pathtofileset
task.
Comments
Post a Comment