5
In netbeans, after a few searches, I was able to edit the file build.xml in order to customize the way the IDE generated my jar and my manifest file. I had to migrate some projects to the eclipse, and I even found the option to build jar, but I need to build my jar with some custom information.
I added the file build.xml as a ANT buildfile in my eclipse project, but when I have it executed, the IDE runs 2x, generating 2 jars files at once.
Follow my file build.xml.
<?xml version="1.0" encoding="UTF-8"?>
<project name="GerOficios" default="makejar" basedir='.'>
<target name="makejar">
<property file="version_info.properties" />
<property name="application.title" value="GerOficios_v6" />
<property name="main.class" value="com/dfmachado/geroficios/View/ListaDeOficiosUI" />
<buildnumber file="build.num" />
<property name="build.version.num" value="${version.number}.${build.number}" />
<tstamp>
<format property="TODAY" pattern="dd/MM/yyyy - HH:mm:ss" />
</tstamp>
<property name="store.jar.name" value="GerOficios ${build.version.num}" />
<property name="store.dir" value="store" />
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar" />
<echo message="Packaging ${application.title} into a single JAR at ${store.jar}" />
<mkdir dir="${store.dir}" />
<jar destfile="${store.dir}/temp_final.jar" basedir="bin" filesetmanifest="skip">
<zipgroupfileset dir="lib" includes="*.jar" />
<manifest>
<attribute name="Main-Class" value="${main.class}" />
<attribute name="SplashScreen-Image" value="com/dfmachado/geroficios/View/image/minerva.png" />
<attribute name="Build-OS" value="${os.name} version ${os.version} on ${os.arch}" />
<attribute name="Java-Version" value="${javac.source}" />
<attribute name="Implementation-Title" value="${application.title}" />
<attribute name="Implementation-Version" value="${build.version.num}" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Built-Date" value="${TODAY}" />
</manifest>
</jar>
<zip destfile="${store.jar}">
<zipfileset src="${store.dir}/temp_final.jar" excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA" />
</zip>
<delete file="${store.dir}/temp_final.jar" />
</target>
</project>
Just to point out, the eclipse generates the jar the way it generated in netbeans, the problem is the xml run 2 times and generate 2 jars, even if I give command only once, as can be seen in the print below:
At @Victorstafusa’s suggestion, I ran the ant via command line in the same project and only one file was created, apparently the problem is some configuration in the eclipse, but I haven’t been able to locate any so far.


Netbeans generates only once or also generates two?
– Victor Stafusa
<property file="version_info.properties" />- What’s in this property file?– Victor Stafusa
@Victorstafusa only one versioning I did manually, only has one line :
version.number=?.?.?.– user28595
If you run ant via command line, what happens?
– Victor Stafusa
@Victorstafusa I’ll be honest, I have no idea how you do it :/ I’m researching how you do it here and already put the exit.
– user28595
Open the prompt, go to your project folder and type
ant. If the prompt says you don’t know theant, put it in the PATH, close the prompt, open again and repeat the process.– Victor Stafusa
@Victorstafusa that strange, via command line creates only one, the problem should be with the eclipse then.
– user28595