antcall causes FileNotFoundException if using executeTarget

Status
Nicht offen für weitere Antworten.

Squish

Neues Mitglied
Hi all,

this is my first post here, so i dont know if it's the right place (sorry if so).

I try to run an ant target within a java program.
My build file (test.xml) is:

Code:
<project name="test" default="usage" basedir=".">
  <target name="test1" >
    <echo message="Target test1" />
    <antcall target="test2"/>
  </target>
  <target name="test2" >
    <echo message="Target test2" />
  </target>
</project>

My java programm is:

Code:
public static void main (String [] a) {
  String buildFileName = "test.xml";
  File buildFile = new File (".",buildFileName);
  Project project = new Project();
  project.init();
  ProjectHelper helper = new ProjectHelperImpl();
  helper.parse(project, buildFile);
  project.executeTarget("test1");	
}

This causes following exception:

Exception in thread "main" test.xml:4: The following error occurred while executing this line:
Code:
java.io.FileNotFoundException: build.xml 
	at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:539)
	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:336)
	at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107)
	at org.apache.tools.ant.Task.perform(Task.java:364)
	at org.apache.tools.ant.Target.execute(Target.java:341)
	at org.apache.tools.ant.Target.performTasks(Target.java:369)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
	at test.Test.main(Test.java:19)
Caused by: java.io.FileNotFoundException: build.xml 
	at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:243)
	at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:140)
	at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:91)
	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:334)
	... 7 more
Caused by: java.io.FileNotFoundException: build.xml 
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:106)
	at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:198)
	... 10 more

If I use
Code:
<ant antfile="test.xml" target="test2"/>
instead it works perfecly. But I don't want to. The target "antcall" was created to call targets within the same build-file, but why build.xml is referenced anywhere?

Might this be an ant bug?
Any ideas?

Tx
 
Status
Nicht offen für weitere Antworten.

Neue Themen


Oben