[ https://issues.apache.org/jira/browse/IVY-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16018794#comment-16018794 ]
ASF GitHub Bot commented on IVY-1555: ------------------------------------- GitHub user jaikiran opened a pull request: https://github.com/apache/ant-ivy/pull/24 Fix IVY-1555 The commit here includes a fix and test case for the issue reported in https://issues.apache.org/jira/browse/IVY-1555 where the absence of a `optional` settings file included in another file, errors out the build. The commit in this PR, takes into account the `optional` attribute value before deciding whether or not to cause the `IOException` to error out or be ignored (with a verbose log message). You can merge this pull request into a Git repository by running: $ git pull https://github.com/jaikiran/ant-ivy ivy-1555 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/ant-ivy/pull/24.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #24 ---- commit ce551f6e92679fca04ef4c3f66950e0959426228 Author: Jaikiran Pai <jaikiran....@gmail.com> Date: 2017-05-21T12:01:47Z IVY-1555 Don't error out if an "optional" file included in ivy settings xml isn't available ---- > Including optional ivysettings of type 'file' doesn't work when file doesn't > exist > ---------------------------------------------------------------------------------- > > Key: IVY-1555 > URL: https://issues.apache.org/jira/browse/IVY-1555 > Project: Ivy > Issue Type: Bug > Affects Versions: 2.4.0 > Reporter: Janek Lehr > Priority: Minor > > 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|https://git-wip-us.apache.org/repos/asf?p=ant-ivy.git;a=blob;f=src/java/org/apache/ivy/core/settings/XmlSettingsParser.java;h=a40cc1ca601ef661b92c1b9ec1ed00fc155bac20;hb=HEAD#l415] > is called before checking the 'optional' attribute, which results in a > [java.io.FileNotFoundException|https://git-wip-us.apache.org/repos/asf?p=ant-ivy.git;a=blob;f=src/java/org/apache/ivy/core/settings/XmlSettingsParser.java;h=a40cc1ca601ef661b92c1b9ec1ed00fc155bac20;hb=HEAD#l457] > 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|https://git-wip-us.apache.org/repos/asf?p=ant-ivy.git;a=blob;f=src/java/org/apache/ivy/core/settings/XmlSettingsParser.java;h=a40cc1ca601ef661b92c1b9ec1ed00fc155bac20;hb=HEAD#l449] > succeeds in urlFromFileAttribute, which returns back to includeStarted where > the 'optional' attribute [is > checked|https://git-wip-us.apache.org/repos/asf?p=ant-ivy.git;a=blob;f=src/java/org/apache/ivy/core/settings/XmlSettingsParser.java;h=a40cc1ca601ef661b92c1b9ec1ed00fc155bac20;hb=HEAD#l421]. > Here is the exception I'm getting > {code} > ==== 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' > {code} > Here is a sanitized version of my ivysettings.xml > {code} > $ 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> > {code} > Changing the include line to > {code} > <include file="file:/path/does/not/exist" > optional="true" /> > {code} > fixes the problem, but I find it kind of annoying to require a URL format > when using the 'file' type. -- This message was sent by Atlassian JIRA (v6.3.15#6346)