|Summary:||Augment task: IllegalStateException when "id" attribute is missing|
|Product:||Ant||Reporter:||Rohan Padhye <rohanpadhye>|
|Component:||Core tasks||Assignee:||Ant Notifications List <notifications>|
|OS:||Mac OS X 10.1|
Description Rohan Padhye 2018-08-25 08:26:00 UTC
Minimum working repro for 'build.xml': ``` <project><augment></augment><target name="init"></target></project> ``` $ ant Buildfile: /path/to/build.xml BUILD FAILED /path/to/build.xml:1: java.lang.IllegalStateException: augment attribute 'id' unset at org.apache.tools.ant.taskdefs.AugmentReference.hijackId(AugmentReference.java:66) at org.apache.tools.ant.taskdefs.AugmentReference.getProxy(AugmentReference.java:45) at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:494) at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:464) at org.apache.tools.ant.Task.maybeConfigure(Task.java:202) at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:200) at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:164) at org.apache.tools.ant.Task.perform(Task.java:347) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:180) at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93) at org.apache.tools.ant.Main.runBuild(Main.java:832) at org.apache.tools.ant.Main.startAnt(Main.java:236) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
Comment 1 Jaikiran Pai 2018-08-25 08:40:53 UTC
As per the manual of this task "id" is a mandatory attribute that you need to set. The build.xml sample, you posted doesn't have that attribute and hence that error.  https://ant.apache.org/manual/Tasks/augment.html
Comment 2 Rohan Padhye 2018-08-25 08:45:40 UTC
(In reply to Jaikiran Pai from comment #1) > As per the manual of this task "id" is a mandatory attribute that you > need to set. The build.xml sample, you posted doesn't have that attribute > and hence that error. > >  https://ant.apache.org/manual/Tasks/augment.html @Jaikiran Pai: There is a difference between a build error that is reported with a simple message and an IllegalStateException being thrown by the core. Specifically, the core method org.apache.tools.ant.ProjectHelper.parse() should throw a BuildException when presented with such a build.xml file as referenced in the manual. However, an unchecked IllegalStateException is thrown instead. This makes programmatic use of the Ant core API difficult.
Comment 3 Jaikiran Pai 2018-08-25 08:47:58 UTC
I see. I misunderstood the original report. You are right, unlike as stated in the manual, this currently isn't throwing a BuildException and indeed appears to be a bug.
Comment 4 Rohan Padhye 2018-08-25 08:59:19 UTC
(In reply to Jaikiran Pai from comment #3) > I see. I misunderstood the original report. You are right, unlike as stated > in the manual, this currently isn't throwing a BuildException and indeed > appears to be a bug. Thanks for the quick response and confirmation!
Comment 5 Jaikiran Pai 2018-08-26 10:41:11 UTC
This has now been fixed in master and 1.9.x branches of Ant. The task will now throw a BuildException as stated in its manual. This will be available 1.10.6 and 1.9.14 releases (whenever they happen).