In Netbeans, after some research, I managed to edit the file build.xml to customize the way the IDE generated my jar and my manifest file. I had to migrate a project for Eclipse, and even found the option to build jar, but I need to build my jar with some personalized information.
I added the file build.xml as a buildfile ANT in my project in eclipse, but when I send execute it, the eclipse runs twice, 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 a jar the way it generated in netbeans, the problem is the ANT run twice and generate 2 jars, even I giving command only once, as can be seen in print below:
Running the ant via the command line in the same project and only one file was created, apparently the problem is some configuration in eclipse, but I have not been able to find any so far.
ANT is a builder you've added in the project builders. Please check it here:
Project -> Right Click -> Properties -> Builders
You can keep it enabled in conjunction with Eclipse's workspace set to "build automatically" - this will trigger automatic builds.
Or, you can deselect the builder from the builders list and run it manually whenever needed!
This SO Q+A is worth a quick (further) read
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With