user1516059
user1516059

Reputation: 33

Create automatically JAR with ANT and Eclipse

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?

Upvotes: 2

Views: 17206

Answers (1)

dash1e
dash1e

Reputation: 7807

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.

Upvotes: 13

Related Questions