1

We have a large amount of apps. They all have a build.xml file located in the projects base directory. I am trying to create an ant script that will go through and call a specific target on each of the build.xml files in all the projects.

Here are the issues:

  1. Some of the projects are in deeper directories than others.
  2. Only some of the projects need to be built at a time.

I was trying to use subant + antfile and defining a CSV of file paths in a properties file, but this did not work. Below is what i have and the error i am getting.

If there is a better way to do this or you know what my problem is, please let me know! Thanks!

This is the property defined in a property file. I am wanting the person running the script to add the file paths in here that are relative to the current location of the script they are running.

projects.to.build=

This is the subant task i am trying to use in the main build script.

    <filelist
        id="projectNames"
        dir="${basedir}"
        files="${projects.to.build}"
    />

    <target name="debugAll" description="Builds all the projects listed in the projectNames.properties file.">
        <subant target="debug" antfile="${projects.to.build}">
        </subant>
    </target>

Here is the error i get when i try to run the build script when there are projects defined in the properties file. I am using the relative path. For example: ..\Apps\AnApp1\build.xml,..\Apps\AnApp2\build.xml,..\OtherApps\foo\AnotherApp1\build.xml

"No Build Path Specified" (at my subant task)
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
prolink007
  • 33,872
  • 24
  • 117
  • 185

2 Answers2

12

You specified the antfile attribute, so ANT was expecting to a single build.xml file.


The subant documentation describes how you can use a fileset as child parameter.

Here's an example:

<project name="Subant demo" default="run-debug-target">
    <target name="run-debug-target">
        <subant target="debug">
            <fileset dir="." includes="**/build.xml" excludes="build.xml"/>
        </subant>
    </target>
</project>

Update

Alternatively a filelist could be used:

<project name="Dry run" default="run">
    <target name="run">
        <subant target="test">
            <filelist dir="projects" files="one/build.xml,two/build.xml,three/build.xml,four/build.xml"/>
        </subant>
    </target>
</project>

Processing the following build files:

  • projects/one/build.xml
  • projects/two/build.xml
  • projects/three/build.xml
  • projects/four/build.xml
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • Yeah, but i want to be able to specify which projects to build by reading in a property set in a properties file. I would like this property to be a CSV of relative paths to a projects build file. And the only way i found that i could do that would be to use `filelist` and the only example i found with `filelist` was with antfile. Is there a way to achieve my goal with `fileset`? – prolink007 Feb 04 '12 at 17:43
  • @prolink007 I've updated my post with a filelist, as requested. You can easily use a property to to hold the list of CSV formatted file names – Mark O'Connor Feb 04 '12 at 20:44
  • Worked great. Thanks for the help! I was trying to over complicate things. =( – prolink007 Feb 06 '12 at 15:37
-1

Is it possible to run the target in the all the build files concurrently ?

E.g.

<project name="Dry run" default="run">
    <target name="run">
        <subant target="test">
            <filelist dir="projects" files="one/build.xml,two/build.xml,three/build.xml,four/build.xml"/>
        </subant>
    </target>
</project>

In this example, is there any way to run target "test" present in all the build files (one/build.xml,two/build.xml,three/build.xml,four/build.xml) concurrently ?

abhi
  • 141
  • 8