ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 32216] New: - Using parse method of ProjectHelper causes import to fail
Date Fri, 12 Nov 2004 22:53:07 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32216>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32216

Using parse method of ProjectHelper causes import to fail

           Summary: Using parse method of ProjectHelper causes import to
                    fail
           Product: Ant
           Version: 1.6.2
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: ngawor@us.ibm.com


I have code to programmatically invoke Ant that uses the deprecated method
configureProject and works fine:

Project proj = new Project();
proj.fireBuildStarted();
proj.init();

try {
     ProjectHelper.configureProject(proj, new File("build.xml"));
     proj.executeTarget(proj.getDefaultTarget());
     proj.fireBuildFinished(null);
    } catch (BuildException e) {
     proj.fireBuildFinished(e);
     throw e;
  }

I replaced the line:
ProjectHelper.configureProject(proj, new File("build.xml"));

with the non-deprecated version:
ProjectHelper helper = ProjectHelper.getProjectHelper();
helper.parse(proj, new File("build.xml"));

This worked fine until I had a build.xml file with an import statement in it.
e.g.
<project name="test" default="test">
	<import file="build2.xml" />
	<target name="test">
		<echo message="Hello World" />
	</target>
</project>

This caused the import task to throw a NullPointer exception in the execute method:

C:\ASCv2Workspace\test\build.xml:2: java.lang.NullPointerException
	at org.apache.tools.ant.Task.perform(Task.java:373)
	at org.apache.tools.ant.Target.execute(Target.java:341)
	at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:133)
	at Test.main(Test.java:31)
--- Nested Exception ---
java.lang.NullPointerException
	at org.apache.tools.ant.taskdefs.ImportTask.execute(ImportTask.java:104)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
	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.helper.ProjectHelper2.parse(ProjectHelper2.java:133)
	at Test.main(Test.java:31)
Exception in thread "main" 

I checked, and the null pointer was thrown by:
  Vector importStack = helper.getImportStack();
because helper is null.  

Comparing the configureProject deprecated method and the parse method, it looks
like parse never sets the "ant.projectHelper" property.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message