Author: gscokart
Date: Sun Apr 13 11:59:27 2008
New Revision: 647607
URL: http://svn.apache.org/viewvc?rev=647607&view=rev
Log:
FIX: Relative include in a settings must be evaluated relatively to the
settings file (IVY-372)
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-absolute-file.xml
(with props)
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-missing-file.xml
(with props)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/OnlineXmlSettingsParserTest.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include.xml
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=647607&r1=647606&r2=647607&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Sun Apr 13 11:59:27 2008
@@ -111,6 +111,7 @@
- FIX: Cachefileset task silently fails with parent dir ".." construct
(IVY-638)
- FIX: SFTP should verify input parameter for hostname (IVY-734)
- FIX: Classpath issues with vfs ftp while being used as a bundle (IVY-785)
+- FIX: Relative include in a settings must be evaluated relatively to the
settings file (IVY-372)
- DOCUMENTATION: Broken link in documentation in Ivy files section, info
element page (IVY-788)
- DOCUMENTATION: Add new cache information to resolver doc (IVY-772) (thanks
to Carlton Brown)
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java?rev=647607&r1=647606&r2=647607&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
Sun Apr 13 11:59:27 2008
@@ -369,20 +369,19 @@
throw new IllegalArgumentException(
"bad include tag: specify file or url to include");
} else {
- Message.verbose("including url: " + propFilePath);
- settingsURL = new URL(propFilePath);
+ settingsURL = new URL(this.settings , propFilePath);
+ Message.verbose("including url: " +
settingsURL.toString());
ivy.setSettingsVariables(settingsURL);
}
} else {
File incFile = new File(propFilePath);
- if (!incFile.exists()) {
- throw new IllegalArgumentException(
- "impossible to include " + incFile + ": file does not
exist");
+ if (incFile.isAbsolute()) {
+ settingsURL = incFile.toURI().toURL();
} else {
- Message.verbose("including file: " + propFilePath);
- ivy.setSettingsVariables(incFile);
- settingsURL = incFile.toURL();
+ settingsURL = new URL(this.settings , propFilePath);
}
+ Message.verbose("including file: " + settingsURL);
+ ivy.setSettingsVariables(incFile);
}
new XmlSettingsParser(ivy).parse(configurator, settingsURL);
} finally {
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/OnlineXmlSettingsParserTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/OnlineXmlSettingsParserTest.java?rev=647607&r1=647606&r2=647607&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/OnlineXmlSettingsParserTest.java
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/OnlineXmlSettingsParserTest.java
Sun Apr 13 11:59:27 2008
@@ -21,6 +21,7 @@
import junit.framework.TestCase;
+import org.apache.ivy.plugins.resolver.ChainResolver;
import org.apache.ivy.plugins.resolver.DependencyResolver;
import org.apache.ivy.plugins.resolver.IvyRepResolver;
import org.apache.ivy.util.url.URLHandler;
@@ -45,6 +46,50 @@
assertTrue(resolver instanceof IvyRepResolver);
}
+
+ public void testIncludeHttpRelativeUrl() throws Exception {
+ //Use a settings file via http that use an include with relative url
+ configureURLHandler();
+ IvySettings settings = new IvySettings();
+ XmlSettingsParser parser = new XmlSettingsParser(settings);
+ parser.parse(new URL(
+
"http://ant.apache.org/ivy/test/ivysettings-include-http-relative-url.xml"));
+
+ DependencyResolver resolver = settings.getResolver("ivyrep");
+ assertNotNull(resolver);
+ assertTrue(resolver instanceof IvyRepResolver);
+ }
+
+
+ public void testIncludeHttpRelativeFile() throws Exception {
+ //Use a settings file via http that use an include with relative file
+ configureURLHandler();
+ IvySettings settings = new IvySettings();
+ XmlSettingsParser parser = new XmlSettingsParser(settings);
+ parser.parse(new URL(
+
"http://ant.apache.org/ivy/test/ivysettings-include-http-relative-file.xml"));
+
+ DependencyResolver resolver = settings.getResolver("ivyrep");
+ assertNotNull(resolver);
+ assertTrue(resolver instanceof IvyRepResolver);
+ }
+
+
+ public void testIncludeHttpAbsoluteFile() throws Exception {
+ //Use a settings file via http that use an include with absolute file
+ //WARNING : this test will only work if the test are launched from the
project root
+ //directory
+ configureURLHandler();
+ IvySettings settings = new IvySettings();
+ XmlSettingsParser parser = new XmlSettingsParser(settings);
+ parser.parse(new URL(
+
"http://ant.apache.org/ivy/test/ivysettings-include-http-absolute-file.xml"));
+
+ DependencyResolver inc = settings.getResolver("includeworks");
+ assertNotNull(inc);
+ assertTrue(inc instanceof ChainResolver);
+ }
+
private void configureURLHandler() {
URLHandlerDispatcher dispatcher = new URLHandlerDispatcher();
URLHandler httpHandler = URLHandlerRegistry.getHttp();
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java?rev=647607&r1=647606&r2=647607&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
Sun Apr 13 11:59:27 2008
@@ -417,6 +417,34 @@
assertEquals("myvalue", settings.getVariable("ivy.test.prop"));
}
+
+ public void testIncludeAbsoluteFile() throws Exception {
+ //WARNING : this test will only work if the test are launched from the
project root
+ //directory
+ IvySettings settings = new IvySettings();
+ XmlSettingsParser parser = new XmlSettingsParser(settings);
+ parser.parse(XmlSettingsParserTest.class.getResource(
+
"ivysettings-include-absolute-file.xml"));
+
+ DependencyResolver inc = settings.getResolver("includeworks");
+ assertNotNull(inc);
+ assertTrue(inc instanceof ChainResolver);
+ }
+
+
+ public void testIncludeMissingFile() throws Exception {
+ IvySettings settings = new IvySettings();
+ XmlSettingsParser parser = new XmlSettingsParser(settings);
+ try {
+ parser.parse(XmlSettingsParserTest.class.getResource(
+
"ivysettings-include-missing-file.xml"));
+ fail("An exception must be throwed");
+ } catch (Exception e) {
+ //An exception must be throwed
+ }
+ }
+
+
public void testParser() throws Exception {
IvySettings settings = new IvySettings();
XmlSettingsParser parser = new XmlSettingsParser(settings);
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-absolute-file.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-absolute-file.xml?rev=647607&view=auto
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-absolute-file.xml
(added)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-absolute-file.xml
Sun Apr 13 11:59:27 2008
@@ -0,0 +1,24 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<ivysettings>
+ <include
file="${user.dir}/test/java/org/apache/ivy/core/settings/ivysettings-macro.xml"/>
+ <resolvers>
+ <mymacro name="includeworks" mymainrep="included/myrep"
mysecondrep="included/secondrep"/>
+ </resolvers>
+</ivysettings>
Propchange:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-absolute-file.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-missing-file.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-missing-file.xml?rev=647607&view=auto
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-missing-file.xml
(added)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-missing-file.xml
Sun Apr 13 11:59:27 2008
@@ -0,0 +1,21 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<ivysettings>
+ <include file="missing-file.xml"/>
+</ivysettings>
Propchange:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include-missing-file.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include.xml?rev=647607&r1=647606&r2=647607&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include.xml
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-include.xml
Sun Apr 13 11:59:27 2008
@@ -17,7 +17,7 @@
under the License.
-->
<ivysettings>
- <include
file="test/java/org/apache/ivy/core/settings/ivysettings-macro.xml"/>
+ <include file="ivysettings-macro.xml"/>
<resolvers>
<mymacro name="includeworks" mymainrep="included/myrep"
mysecondrep="included/secondrep"/>
</resolvers>