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=38622>.
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=38622
Summary: NullPointerException raised if deprecated
ProjectHelper.configureProject is not called
Product: Ant
Version: 1.6.5
Platform: Other
OS/Version: other
Status: NEW
Severity: normal
Priority: P2
Component: Core
AssignedTo: dev@ant.apache.org
ReportedBy: eross@m-qube.com
ImportTask raises NPE unless static configureProject is called
e.g.
[junit] java.lang.NullPointerException
[junit] at
org.apache.tools.ant.taskdefs.ImportTask.execute(ImportTask.java:96)
[junit] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[junit] at org.apache.tools.ant.Task.perform(Task.java:364)
[junit] at org.apache.tools.ant.Target.execute(Target.java:341)
[junit] at
org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
[junit] at AntUtil.createProject(AntUtil.java:67)
Example client class:
public static Project createProject(File buildFile, Properties prop) throws
BuildException {
sLog.debug("createProject file=" + buildFile + " prop=" + prop);
Project project = new Project();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
project.setCoreLoader(cl);
project.fireBuildStarted();
project.init();
ProjectHelper ph = ProjectHelper.getProjectHelper();
// ProjectHelper.configureProject is deprecated but if <import/>
// is used generates NullPointerException ... d'oh
ph.configureProject(project, buildFile);
ph.parse(project, buildFile);
for (Iterator i = prop.entrySet().iterator(); i.hasNext(); ) {
Map.Entry me = (Map.Entry)i.next();
project.setUserProperty((String)me.getKey(), (String)me.getValue());
}
return project;
}
Problem code:
src/main/org/apache/tools/ant/taskdefs/ImportTask.java
public void execute() {
if (file == null) {
throw new BuildException("import requires file attribute");
}
if (getOwningTarget() == null
|| !"".equals(getOwningTarget().getName())) {
throw new BuildException("import only allowed as a top-level task");
}
ProjectHelper helper =
(ProjectHelper) getProject().getReference("ant.projectHelper");
^^^^^^^^^^ helper is null unless ProjectHelper.configureProject is called
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
|