Thursday, June 20, 2013

How to copy a folder with Ant JAR task?

When packaging a Jar using ANT, usually I’ll just don’t care the file structure and dump whatever thing into root directory of a package. The code below showing you a clear picture on how the real thing works:
<jar basedir="build/classes" destfile="${lib.dir}/MyPackage.jar">
    <fileset dir="${lib.dir}">
          <include name="*.jar">
    </fileset>
    
    ... 
But somehow there is a situation where the requirement from my superior was so stubborn that I have to follow the existing file structure as in the development. Meaning that all libraries must locate inside lib folder. Fortunately nothing much change in the build.xml, see the code:
    <jar basedir="build/classes" destfile="${lib.dir}/MyPackage.jar">
       <fileset dir=".">
          <include name="${lib.dir}/*.jar">
       </fileset>
    

No comments: