Mads Andersen
Mads Andersen

Reputation: 3153

"Ant all" not working for me

I have got involved in a project. This project uses ant which is not something I am comfortable with. I have checked out the source code and tried running ant on the most outer directory.

Running 'ant' in commando prompt takes 1 sec and I get a BUILD SUCCESFULL message. If I run 'ant all' I get a

BUILD FAILED. Java.io.IOExceptio: Cannot run program "ant": CreateProcess=2, the system cannot find the file specified and then a long stacktrace.

Most of the people on the project runs OS-X while I use Windows XP.

Any help or information is appreciated :)

EDIT:

<target name="-all-submodules">     
        <subantlight target="all">
            <filelist refid="ordered_build_files"/>
        </subantlight>
</target>

In another xml file

<macrodef name="subantlight">
        <attribute name="target"/>
        <element name="files" optional="no" implicit="true" description="Filessets/lists of build files"/>
        <sequential>
            <apply executable="ant" failonerror="true">
              <arg value="-f"/>
              <srcfile/>
              <arg value="@{target}"/>
              <files/>
            </apply>
        </sequential>
</macrodef>

This is what throws IOException when it hits the line with "apply executeable..".

UPDATED EDIT: If i set the absolute path like this

<macrodef name="subantlight">
            <attribute name="target"/>
            <element name="files" optional="no" implicit="true" description="Filessets/lists of build files"/>
            <sequential>
                <apply executable="MyAbsolutePathHereToAnt.bat" failonerror="true">
                  <arg value="-f"/>
                  <srcfile/>
                  <arg value="@{target}"/>
                  <files/>
                </apply>
            </sequential>
    </macrodef>

Everything works.

I have set ANT_HOME to my ant directory. I have set my JAVA_HOME to Java JDK directory. In my PATH I have set %ANT_HOME%\bin;%JAVA_HOME%\bin

Calling echo %ANT_HOME% produces the right path.

I can't see what I am during wrong here.

Upvotes: 4

Views: 2884

Answers (2)

Andreas Dolk
Andreas Dolk

Reputation: 114767

ant with no attributes calls the default target on the build.xml file on the curent path. 'ant all' will call the 'all' target on the same build file.

First - double check the default ant target - is it 'all' or something different? I guess, the default target is not 'all' in your case and the 'all' build includes a build target, that itself calls ant. And this causes the problem.

Hard to tell from here, but scan the build file for an <ant> task inside some <target>. The IO error smells a bit like a violation of user access rights or missing files near/within this <ant> task.

EDIT

the build.xml starts with something like

<project name="Name" default="compile" basedir="/src">

The 'default' attribute names the default target. If the attribute is missing, all top level targets are executed (since ant 1.6) which should include all in your case.

If it works 'for everyone else' then 'everyone else' might have a different environment. Have a look at the environment variable ant references in the script (like 'env.JAVA_HOME' and so on) and compare with the actual environment. Maybe you find a broken path.

Upvotes: 4

Jesper
Jesper

Reputation: 206786

Do you have the bin directory of your Ant installation in your PATH? If not, then add it.

It looks like the all target tries to execute Ant (recursively) but can't find it.

Upvotes: 1

Related Questions