Details
Description
The ivy:buildlist Ant task is erroring when it encounters an absolute path to a parent Ivy module specified in the /ivy-module/info/extends element's location attribute. This problem is not unique to Ivy 2.3.0-rc1; I've seen it in Ivy 2.2.0.
I can verify that the parent ivy.xml file is there at the specified path. If I specify a relative path to the parent ivy.xml, buildlist works.
In my test case, which I explain shortly, an absolute path for the extends attribute produces this error:
...\testAbsolutePathToParent\multimodule-build\build.xml:28: impossible to parse ivy file for ...\testAbsolutePathToParent\croatia\build.xml: ivyfile=...\testAbsolutePathToParent\croatia\ivy.xml exception=java.text.ParseException: Problem occurred while parsing ivy file: null in file:/.../testAbsolutePathToParent/croatia/ivy.xml
at org.apache.ivy.ant.IvyBuildList.doExecute(IvyBuildList.java:215)
at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:277)
...
Caused by: java.text.ParseException: Problem occurred while parsing ivy file: null in file:/.../testAbsolutePathToParent/croatia/ivy.xml
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser$Parser.parse(XmlModuleDescriptorParser.java:301)
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser.parseDescriptor(XmlModuleDescriptorParser.java:116)
at org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry.parseDescriptor(ModuleDescriptorParserRegistry.java:88)
at org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser.parseDescriptor(AbstractModuleDescriptorParser.java:48)
at org.apache.ivy.ant.IvyBuildList.doExecute(IvyBuildList.java:207)
... 35 more
Caused by: org.xml.sax.SAXException: Problem occurred while parsing ivy file: null
...
— Nested Exception —
java.text.ParseException: Problem occurred while parsing ivy file: null in file:/.../testAbsolutePathToParent/croatia/ivy.xml
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser$Parser.parse(XmlModuleDescriptorParser.java:301)
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser.parseDescriptor(XmlModuleDescriptorParser.java:116)
at org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry.parseDescriptor(ModuleDescriptorParserRegistry.java:88)
...
Caused by: org.xml.sax.SAXException: Problem occurred while parsing ivy file: null
java.lang.NullPointerException
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser$Parser.startElement(XmlModuleDescriptorParser.java:386)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:506)
...
Caused by: java.lang.NullPointerException
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser$Parser.parseOtherIvyFile(XmlModuleDescriptorParser.java:659)
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser$Parser.extendsStarted(XmlModuleDescriptorParser.java:443)
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser$Parser.startElement(XmlModuleDescriptorParser.java:327)
... 57 more
This is what occurs when the haltOnError attribute is set to "true" on ivy:buildlist. If I set haltOnError="false" in my test case, the exception goes away, but I see the following build order:
1. croatia
2. germany
3. ireland
4. bootstrap-parent
5. master-parent
What's wrong about this build order is that germany depends on ireland and croatia depends on master-parent, in addition to extending it, and yet germany comes before ireland and croatia comes before master-parent.
The roughly correct build order, as exhibited with a relative path to the parent, is:
1. bootstrap-parent
2. master-parent
3. croatia
4. ireland
5. germany
So, in addition to being incorrect, this behavior is just plain inconsistent.
TEST CASE INSTRUCTIONS:
I've attached a ZIP containing two standalone test cases, each consisting of a suite of Ant projects that together comprise a multimodule build whose build order is to be determined by the ivy:buildlist task:
- testAbsolutePathToParent: The extends@location attribute uses an absolute path.
- testRelativePathToParent: The extends@location attribute uses an absolute path.
When running Ant from one of these test cases, you need to specify the location of the Ivy 2.3.0-rc1 installation using one of the following:
- an IVY_DIR environment variable
- an env.IVY_DIR user property, i.e. -Denv.IVY_DIR=...
- an ivy.dir user property, i.e. -Divy.dir=...
When running Ant for testAbsolutePathToParent, you need to specify the absolute path to the BuildlistAndExtendsIntegrationTest/testAbsolutePathToParent/master-parent directory using either of the following:
- a MASTER_PARENT_DIR environment variable
- an env.MASTER_PARENT_DIR user property, i.e. -Denv.MASTER_PARENT_DIR=...
To run the build in either of these suites, go to the multimodule-build directory, and execute "ant" or "ant init"—while specifying the Ivy installation directory and the master-parent directory. You can also run "ant cleancache" to clear out the Ivy cache. However, you shouldn't need to do this regularly because each of these test cases uses its own dedicated Ivy cache.
NOTE: This issue is broached in the email thread "buildlist task chokes on absolute path to parent Ivy module" on the ivy-user mailing list.