Eclipse executes the ANT xml buildfile 2 times, even if it only has one run

Asked

Viewed 154 times

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:

inserir a descrição da imagem aqui

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?

  • <property file="version_info.properties" /> - What’s in this property file?

  • @Victorstafusa only one versioning I did manually, only has one line : version.number=?.?.?.

  • If you run ant via command line, what happens?

  • @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.

  • Open the prompt, go to your project folder and type ant. If the prompt says you don’t know the ant, put it in the PATH, close the prompt, open again and repeat the process.

  • @Victorstafusa that strange, via command line creates only one, the problem should be with the eclipse then.

Show 2 more comments

1 answer

1


After ask on Soen simultaneously, I was able to locate the cause of the problem. Basically it was to have added the buildfile from ant in the settings of Builder of the project. Since the eclipse, by default, compiles the project automatically (even to speed up the execution of the project), by having the ant separately, it also ran the reference to the buildfile that I added to Builder.

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

inserir a descrição da imagem aqui

And to get there the way is:

Project -> Right Click -> Properties -> Builders

Browser other questions tagged

You are not signed in. Login or sign up in order to post.