Hi, I’m trying to allow a user defined settings file to override the default
one if it exists
<include file="${ivy.default.ivy.user.dir}/ivysettings.xml"
optional="true" />
But I'm getting:
Caused by: java.io.FileNotFoundException: C:\Users\rob\.ivy2\ivysettings.xml
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)
... 39 more
I think the problem is in the XmlSettingsParser urlFromFileAttrubte method
in that it does a file exists check for absolute files:
if (incFile.isAbsolute()) {
if (!incFile.exists()) {
throw new FileNotFoundException(incFile.getAbsolutePath());
}
but this happens before the optional check in the calling code:
settingsURL = urlFromFileAttribute(propFilePath);
Message.verbose("including file: " + settingsURL);
if ("file".equals(settingsURL.getProtocol())) {
try {
File settingsFile = new File(new URI(settingsURL.toExternalForm()));
String optional = (String) attributes.get("optional");
if ("true".equals(optional) && !settingsFile.exists()) {
return;
}
So I'm guessing this is a bug...
Please can you advise a workaround, or is there an alternative recommended
way for having an optional user settings file?
Many thanks,
Rob