views:

530

answers:

2

I am a NetBeans user and I wanted to reduce the number of steps required to build the project. I used to have two scripts: "build.xml"(created by NetBeans) and "build-module.xml"(my script), and I tried to merge them both into a single step. I renamed "build.xml" to "xbuild.xml" and renamed "build-module.xml" to "build.xml"(so NetBeans would execute my script instead).

<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<project name="BuildModules" default="default" basedir="..">
    <description>Runs all of the build-module scripts</description>

   <target name="clean">
        <echo message="1"/>
        <subant target="clean">
            <fileset dir="Core" includes="xbuild.xml"/>
        </subant>
        <echo message="2"/>
        <ant antfile="Pineapple/build.xml" target="clean"/>
        <echo message="3"/>
        <!--some more commands and some more echo commands which never get executed-->
   </target>
</project>

This is a reduced version of the script. I depend on clean from xbuild.xml to perform the common tasks but I still need to use the name "clean" so that NetBeans will execute it. However, the ANT script runs in an eternal loop(keeps reaching steps 1 and 2, never reaches 3). I can't change the name of the script of xbuild.xml nor build.xml. Also, the question Ant build scripts, antcall, dependancies, etc did not help. How to solve this recursive problem?

EDIT: xbuild.xml only references build-impl.xml, which is a relatively automatically generated large file, that does not link back to build.xml. Pineapple/build.xml is very similar. So, it seems that it's reaching Pineapple/build.xml and going back.

Pineapple/build.xml clean target contains this:

<target name="clean">
    <echo message="P1"/>
    <subant target="clean">
        <fileset dir="Pineapple" includes="xbuild.xml"/>
    </subant>
    <echo message="P2"/>
</target>

Where P1 is printed, but P2 is not. Once again Pineapple/xbuild.xml links to Pineapple/nbproject/build-impl.xml (same name as the other one, but different folder)

A: 

You should post the contents of the other file; I'm not sure I understand what you are doing.

Further, why not just have all ant commands in build.xml? That is the standard way to do things and would be a lot easier to maintain and deal with.

davetron5000
I intend to merge build.xml and xbuild.xml once I solve this problem, but I can not merge the multiple build.xml because the application it is divided in multiple separated projects. I can not change build-impl.xml because it is automatically generated by NetBeans, so mine would be overwritten.
luiscubal
A: 

Nevermind. Just for future reference, Pineapple/build-impl.xml did link back to Core/build.xml... Sorry if I wasted your time.

luiscubal