Bug 49015

Summary: Invoking "ant -p" fails when a path with ID "ant.targets" exists.
Product: Ant Reporter: Stig Inge Lea Bjørnsen <stiginge>
Component: CoreAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 1.8.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Stig Inge Lea Bjørnsen 2010-03-29 11:00:21 UTC
Invoking "ant -p" fails due to the existence of the path with ID "ant.targets" in the following build.xml file:

<project>
  <path id="ant.targets"/>
</project>

Command line output:

$ ant -p
Buildfile: C:\devel\workspace\ant-property-test\build.xml
java.lang.ClassCastException: org.apache.tools.ant.types.Path cannot be cast to java.util.Vector
java.lang.ClassCastException: org.apache.tools.ant.types.Path cannot be cast to java.util.Vector
        at org.apache.tools.ant.types.Description.getDescription(Description.java:76)
        at org.apache.tools.ant.Project.getDescription(Project.java:774)
        at org.apache.tools.ant.Main.printDescription(Main.java:1027)
        at org.apache.tools.ant.Main.runBuild(Main.java:789)
        at org.apache.tools.ant.Main.startAnt(Main.java:218)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
org.apache.tools.ant.types.Path cannot be cast to java.util.Vector

Line 76 of Description.java is as follows:

Vector targets = (Vector) project.getReference(ProjectHelper2.REFID_TARGETS);

The return value of project.getReference in line 76 is now the org.apache.tools.ant.types.Path with ID "ant.targets" from the build file.

If "ant.targets" is a reserved ID it would be nice to at least have Ant print a warning message if it is used in a build file.