22

I've got an ant jar task:

<target name="jar">
    <jar destfile="${generated.jars.dir}/hello-${environment}.jar">
        <fileset dir="${generated.classes.dir}"/>
        <fileset dir="${environment.dir}/${environment}" includes="config.xml"/>
    </jar>
</target>

How can I force the config.xml file to be pushed to a specific directory in the jar rather than at the root level, say in /database/config.xml or something like that...

PS: The reason for doing this is that I can have a hello-local.jar, hello-dev.jar, hello-qa.jar, etc.

Stephane Grenier
  • 15,527
  • 38
  • 117
  • 192

3 Answers3

29

Use a zipfileset like this:

<jar destfile="${generated.jars.dir}/hello-${environment}.jar">
    <fileset dir="${generated.classes.dir}"/>
    <zipfileset dir="${environment.dir}/${environment}" 
                includes="config.xml"
                fullpath="database/config.xml"/>
</jar>
martin clayton
  • 76,436
  • 32
  • 213
  • 198
kaboom
  • 612
  • 1
  • 8
  • 15
6

You want zipfileset:

<zipfileset dir="${environment.dir}/${environment}" includes="config.xml" prefix="database"/>

or:

<zipfileset dir="${environment.dir}/${environment}" includes="config.xml" fullpath="database/config.xml"/>
Brett Kail
  • 33,593
  • 2
  • 85
  • 90
  • so if I understand you correctly, you're suggesting that after the jar has been created to stuff in the config file through zip? – Stephane Grenier Sep 16 '09 at 18:30
  • No, since the <jar> task extends the <zip> task it supports nesting zipfileset and zipgroupfileset directly. –  Sep 18 '09 at 12:05
1
<!-- Generate EJBs -->
  <javadoc destdir="${ejb.build.dir}/src" classpathref="ejb.class.path" docletpath="${wl.home}/lib/ejbgen.jar" doclet="weblogic.tools.ejbgen.EJBGen" maxmemory="512m" docletpathref="class.path" failonerror="true" additionalparam="-descriptorDir ${ejb.build.dir}/src/META-INF -wls81 -forceGeneration">
   <fileset dir="${ejb.build.dir}/src" includes="**/ejb/*Bean.java,**/ejb/**/*Bean.java, **/ejb/enterprisemanagement/*EJB.java, **/ejb/sitemanagement/*EJB.java, kaas/gateways/rdm/**" excludes="**/agwmgmt/*.java,**/dstprofilemgmt/*.java, **/KaASBaseSessionBean.java,**/com/hns/iag/kaas/rdm/**">
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Justin
  • 11
  • 1