Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.4.0
-
None
-
None
Description
The 'optional' attribute of the <include> tag in <ivysettings> doesn't work for regular file paths when using the 'file' include type, and the file doesn't exist. It requires using URL format when providing the file path, i.e. 'file:/path/to/settings'.
Also, 'optional' doesn't do anything when using the 'url' type for include.
The reason it fails is because urlFromFileAttribute is called before checking the 'optional' attribute, which results in a java.io.FileNotFoundException when trying to determine the URL path of the file that doesn't exist.
My current work around is to prepend the file path with 'file:' so that creating a URL instance succeeds in urlFromFileAttribute, which returns back to includeStarted where the 'optional' attribute is checked.
Here is the exception I'm getting
==== stderr ==== java.text.ParseException: failed to load settings from file:/Users/janek.lehr/<removed>/ivysettings.xml: io problem while parsing config file: /path/does/not/exist at org.apache.ivy.core.settings.XmlSettingsParser.doParse(XmlSettingsParser.java:165) at org.apache.ivy.core.settings.XmlSettingsParser.parse(XmlSettingsParser.java:150) at org.apache.ivy.core.settings.IvySettings.load(IvySettings.java:393) at org.apache.ivy.Ivy.configure(Ivy.java:417) at org.apache.ivy.Main.initSettings(Main.java:452) at org.apache.ivy.Main.run(Main.java:247) at org.apache.ivy.Main.main(Main.java:219) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.martiansoftware.nailgun.NGSession.run(NGSession.java:280) Caused by: org.xml.sax.SAXException: io problem while parsing config file: /path/does/not/exist java.io.FileNotFoundException: /path/does/not/exist at org.apache.ivy.core.settings.XmlSettingsParser.startElement(XmlSettingsParser.java:234) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509) at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1339) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327) at javax.xml.parsers.SAXParser.parse(SAXParser.java:274) at org.apache.ivy.core.settings.XmlSettingsParser.doParse(XmlSettingsParser.java:160) ... 11 more Caused by: java.io.FileNotFoundException: /path/does/not/exist at org.apache.ivy.core.settings.XmlSettingsParser.urlFromFileAttribute(XmlSettingsParser.java:457) at org.apache.ivy.core.settings.XmlSettingsParser.includeStarted(XmlSettingsParser.java:415) at org.apache.ivy.core.settings.XmlSettingsParser.startElement(XmlSettingsParser.java:211) ... 25 more ==== stdout ==== :: loading settings :: file = /Users/janek.lehr/<removed>/ivysettings.xml setting 'ivy.settings.dir' to '/Users/janek.lehr/<removed>' setting 'ivy.conf.dir' to '/Users/janek.lehr/<removed>' setting 'ivy.settings.file' to '/Users/janek.lehr/<removed>/ivysettings.xml' setting 'ivy.conf.file' to '/Users/janek.lehr/<removed>/ivysettings.xml' setting 'ivy.settings.url' to 'file:/Users/janek.lehr/<removed>/ivysettings.xml' setting 'ivy.conf.url' to 'file:/Users/janek.lehr/<removed>/ivysettings.xml' setting 'ivy.settings.dir.url' to 'file:/Users/janek.lehr/<removed>/' setting 'ivy.default.ivy.user.dir' to '/Users/janek.lehr/.ivy2' setting 'ivy.home' to '/Users/janek.lehr/.ivy2' no default ivy user dir defined: set to /Users/janek.lehr/.ivy2 setting 'ivy.log.modules.in.use' to 'false' setting 'ivy.resolver.default.check.modified' to 'false' setting 'ivy.default.always.check.exact.revision' to 'false' setting 'ivy.retrieve.pattern' to '${ivy.lib.dir}/[artifact]-[revision](-[classifier]).[ext]' setting 'ivy.configurations' to '*' setting 'ivy.buildlist.ivyfilepath' to 'ivy.xml' setting 'ivy.status' to 'integration' setting 'ivy.resolve.default.type.filter' to '*' setting 'ivy.project.dir' to '${basedir}' setting 'ivy.dep.file' to 'ivy.xml' 'ivy.settings.file' already set: discarding 'ivysettings.xml' setting 'ivy.report.output.pattern' to '[organisation]-[module]-[conf].[ext]' setting 'ivy.cache.ttl.default' to '10s' setting 'ivy.publish.src.artifacts.pattern' to '${ivy.distrib.dir}/[type]s/[artifact]-[revision](-[classifier]).[ext]' setting 'ivy.deliver.ivy.pattern' to '${ivy.distrib.dir}/[type]s/[artifact]-[revision](-[classifier]).[ext]' setting 'ivy.build.artifacts.dir' to '${ivy.project.dir}/build/artifacts' setting 'ivy.checksums' to 'sha1,md5' setting 'ivy.distrib.dir' to '${ivy.project.dir}/distrib' setting 'ivy.lib.dir' to '${ivy.project.dir}/lib'
Here is a sanitized version of my ivysettings.xml
$ cat <removed>/ivysettings.xml <ivysettings> <include file="/path/does/not/exist" optional="true" /> <resolvers> <chain returnFirst="true"> <ibiblio name="ibiblio" m2compatible="true" /> (removed rest of the chain) </chain> </resolvers> </ivysettings>
Changing the include line to
<include file="file:/path/does/not/exist" optional="true" />
fixes the problem, but I find it kind of annoying to require a URL format when using the 'file' type.
Attachments
Issue Links
- links to