How to include jar file in lib folder from ear file using ant?

I have the following folder structure:

project.ear lib folder ProjectEJBClient.jar META-INF folder projectEJB.jar 

My build.xml contains the following lines to create an EAR package

 <ear destfile="${build.dir}/myapp.ear" appxml="${src.dir}/metadata/application.xml"> <fileset dir="${build.dir}" includes="ProjectEJBClient.jar"/> <fileset dir="${build.dir}" includes="projectEJB.jar"/> </ear> 

The above code cannot create an EAR package with the lib folder that includes the ProjectEJBClient.jar file

I want to create a lib folder and copy ProjectEJBClient.jar to this lib folder.

After this process, I want to create an EAR project with this lib folder.

I do not know how to create the lib folder and copy ProjectEJBClient.jar to this folder and include this folder in project.ear.

+6
source share
2 answers

Use zipfileset :

  <ear destfile="${build.dir}/myapp.ear" appxml="${src.dir}/metadata/application.xml"> <zipfileset dir="." prefix="lib"> <include name="ProjectEJBClient.jar"/> </zipfileset> <fileset dir="${build.dir}" includes="projectEJB.jar"/> </ear> 

prefix="lib" will ensure that the gang is under /lib in the ear.

+7
source

In my case, this did not work, because I needed to include several files, and I decided to use zipfileset differently, under apache-ant -1.9.1 and jdk1.7.0_60:

 <ear earfile="${dst_dir}/${ear_file}" appxml="${dep_dir}/ear/application.xml"> <zipfileset dir="${m2.home}/commons-codec/commons-codec/1.9" prefix="lib" includes="**/*.jar"/> <zipfileset dir="${m2.home}/log4j/log4j/1.2.17" prefix="lib" includes="**/*.jar"/> <fileset dir="${dst_dir}" includes="${jar_file}"/> <fileset dir="${dst_dir}" includes="${war_file}"/> </ear> 
0
source

Source: https://habr.com/ru/post/912746/


All Articles