Create automatically JAR with ANT and Eclipse

16,776

Generally to create jar files in Eclipse I do this things:

  1. create an ant file with the necessary code to create the jar file I need
  2. configure the ant file to be processed when something change in my project files: and to do this I open the project properties, I choose Builders, "New..." and I add a Ant builder that use my ant file

In the ant files I put for example something similar:

<project name="My Project" default="createjar">    
  <property name="projectHome" location="." />
  <target name="createjar">
    <jar destfile="${projectHome}/file.jar" basedir="${projectHome}/bin" />
  </target>    
</project>

You can add other instructions to the ant file and process whatever you need after the jar creation. But my suggestion is to not launch JUnit test on very file change, can be very ugly.

Share:
16,776
user1516059
Author by

user1516059

Updated on June 05, 2022

Comments

  • user1516059
    user1516059 almost 2 years

    I want to make the file build automatically using Eclipse. I need this file creates the JAR of the application. And if it were possible, I would like to insert the command to pass some test of JUnit. How can I do all of this automatically?

  • user1516059
    user1516059 almost 12 years
    I know this, but now I want to do automatically