tags:

views:

65

answers:

2

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.

+1  A: 

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.

Jesper
Yes I have. It does execute ant, but I am not sure if it can find it or not.
bobjink
+4  A: 

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.

Andreas_D
Thanks for the help! I am not sure how to check if 'all' is the default ant target. This was the command I was told to use. I have tried the other ones and they fail to. You are right that it calls a build target that itselfs calls ant. Its hard to understand the ant syntax but I have a feeling you are right about some missing files. But this does not make sense since it works for everyone else :/
bobjink
Ok I have seen your updated answer. Default is not 'all' it points to a "private helper" target. Ie. it starts with a '-' symbol so I can not call it from commando prompt.
bobjink
... but if you need the `all` target, then you have to fix/change your environment. Or the script.
Andreas_D
I am being a bit noobie here: I have run ant -diagnostics and can see that my ant version is 1.8.1 and that java points to my JDK1.6.0_20 folder which is what I have been told to use.
bobjink
Can you edit your question and post this one target which itself calls ant? or at least the <ant> task inside?
Andreas_D
I have updated it now.
bobjink
Updated it again.
bobjink
Great, looks like you made it! The apply task executes a system command - in this case it works like you would type `ant -f ...` on the console. And during the ant run the command obviously can't be execute. I'd leave it like this for it seems to work for you.
Andreas_D
Thanks for all the help :)
bobjink