Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include a jar file into a lib folder of an ear file using ant?

Tags:

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 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 can't create an EAR package with lib folder which includes the ProjectEJBClient.jar file

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

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

I don't know how to create lib folder and copy ProjectEJBClient.jar into that folder and include this folder into project.ear.

like image 936
user1314506 Avatar asked Apr 09 '12 11:04

user1314506


People also ask

How do you make an EAR file with ant?

To Build an EAR File Using the Ant Script:Generate the Ant script for each project in the EAR. Generate the Ant script for the EAR project. Change to the Eclipse directory for the EAR project.


1 Answers

Use a 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>

The prefix="lib" will make sure, that the jar will be under /lib in your ear.

like image 59
oers Avatar answered Nov 15 '22 07:11

oers