Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include file in Jar through Ant at specific location

Tags:

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.

like image 361
Stephane Grenier Avatar asked Sep 16 '09 18:09

Stephane Grenier


1 Answers

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> 
like image 89
kaboom Avatar answered Oct 28 '22 00:10

kaboom