Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 947
user1516059 Avatar asked Jul 26 '26 00:07

user1516059


1 Answers

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.

like image 144
dash1e Avatar answered Jul 28 '26 13:07

dash1e