Bug 49015 - Invoking "ant -p" fails when a path with ID "ant.targets" exists.
Summary: Invoking "ant -p" fails when a path with ID "ant.targets" exists.
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.8.2
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-29 11:00 UTC by Stig Inge Lea Bjørnsen
Modified: 2010-12-27 11:12 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.