Eclipse executes the xml buildfile of ANT 2 times, even having to execute only once

6

In netbeans, after a few searches, I was able to edit the build.xml file to customize the way the IDE generated my jar and my manifest file. I had to migrate some projects to 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 an ANT buildfile into my project in eclipse, but when I say execute it, the IDE runs 2x, generating 2 jars files at once.

Follow my build.xml file.

<?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 that the xml is executed 2 times and generate 2 jars, even though I give the command only once, as can be seen in the print below: / p>

After suggestion of @VictorStafusa, I ran the ant via command line in the same project and only one file was created, apparently the problem is some configuration in eclipse, but I could not locate any so far.

    
asked by anonymous 16.11.2016 / 11:55

1 answer

2

After ask in SOEn simultaneously, I was able to locate the cause of the problem. Basically it was to have added the ant buildfile file in the Builder settings of the project. Since eclipse by default compiles the project automatically (even to speed up the execution of the project), by running separate ant , it also executed the buildfile reference that I added in builder .

The solution was to remove / disable the build.xml file from the Builder settings of the project:

And to get there, the path is:

  

Project - > Right Click - > Properties - > Builders

    
16.11.2016 / 17:36