Repository: ant-ivy Updated Branches: refs/heads/master 4b6e0bd17 -> c87126545
Revert 4b6e0bd179c5f728761c953249b6dda4d33fe18a since it introduces failures on Windows (needs investigation) This reverts commit 4b6e0bd179c5f728761c953249b6dda4d33fe18a. Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/c8712654 Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/c8712654 Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/c8712654 Branch: refs/heads/master Commit: c871265452e473224b3cf4f0f66497691b75d7b7 Parents: 4b6e0bd Author: Jaikiran Pai <[email protected]> Authored: Mon Jul 3 15:13:18 2017 +0530 Committer: Jaikiran Pai <[email protected]> Committed: Mon Jul 3 15:13:18 2017 +0530 ---------------------------------------------------------------------- .../parser/xml/XmlModuleDescriptorParser.java | 9 ++-- .../xml/XmlModuleDescriptorParserTest.java | 55 ++++---------------- .../xml/foo%2Fbar/hello/test-ivy-extends.xml | 25 --------- .../plugins/parser/xml/foo%2Fbar/parent-ivy.xml | 27 ---------- 4 files changed, 16 insertions(+), 100 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/c8712654/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java index 63ed1f3..cc640a8 100644 --- a/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java +++ b/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java @@ -670,11 +670,12 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser { File file = new File(location); if (!file.isAbsolute()) { - final URL url = settings.getRelativeUrlResolver().getURL(descriptorURL, location); - if (!url.getProtocol().equals("file")) { - throw new IOException("Resolved location " + url + ", of parent module descriptor, is not a file"); + URL url = settings.getRelativeUrlResolver().getURL(descriptorURL, location); + try { + file = new File(new URI(url.toExternalForm())); + } catch (URISyntaxException e) { + file = new File(url.getPath()); } - file = new File(url.getPath()); } file = FileUtil.normalize(file.getAbsolutePath()); http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/c8712654/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java index e2a62dd..390d713 100644 --- a/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java +++ b/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java @@ -17,6 +17,15 @@ */ package org.apache.ivy.plugins.parser.xml; +import java.io.File; +import java.io.IOException; +import java.text.ParseException; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashSet; + import org.apache.ivy.Ivy; import org.apache.ivy.core.module.descriptor.Artifact; import org.apache.ivy.core.module.descriptor.Configuration; @@ -42,26 +51,13 @@ import org.apache.ivy.util.DefaultMessageLogger; import org.apache.ivy.util.FileUtil; import org.apache.ivy.util.Message; import org.apache.ivy.util.XMLHelper; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import java.io.File; -import java.io.IOException; -import java.text.ParseException; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.HashSet; -import java.util.Set; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParserTester { private IvySettings settings = null; @@ -1451,33 +1447,4 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse assertEquals("mymodule", artifacts[0].getName()); assertEquals("jar", artifacts[0].getType()); } - - /** - * Tests that when the <code>location</code> attribute of the <code>extends</code> element of a module descriptor - * file, includes any characters that {@link java.net.URI} considers as encoded characters (for example <code>%2F</code>) - * then the module descriptor and the location of the parent descriptor, are resolved and parsed correctly. - * - * @throws Exception - * @see <a href="https://issues.apache.org/jira/browse/IVY-1562">IVY-1562</a> for more details - */ - @Test - public void testExtendsEncodedLocation() throws Exception { - final ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("foo%2Fbar/hello/test-ivy-extends.xml"), true); - assertNotNull("Parsed module descriptor is null", md); - assertEquals("Unexpected org for the parsed module descriptor", "myorg", md.getModuleRevisionId().getOrganisation()); - assertEquals("Unexpected module name for the parsed module descriptor", "mymodule", md.getModuleRevisionId().getName()); - assertEquals("Unexpected revision for the parsed module descriptor", "1.0.0", md.getModuleRevisionId().getRevision()); - - final Configuration[] confs = md.getConfigurations(); - assertNotNull("No configurations found in module descriptor", confs); - assertEquals("Unexpected number of configurations found in module descriptor", 3, confs.length); - - final Set<String> expectedConfs = new HashSet<>(Arrays.asList("parent-conf1", "parent-conf2", "conf2")); - for (final Configuration conf : confs) { - assertNotNull("One of the configurations was null in module descriptor", conf); - assertTrue("Unexpected configuration " + conf.getName() + " found in parsed module descriptor", expectedConfs.remove(conf.getName())); - } - assertTrue("Missing configurations " + expectedConfs + " from the parsed module descriptor", expectedConfs.isEmpty()); - - } } http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/c8712654/test/java/org/apache/ivy/plugins/parser/xml/foo%2Fbar/hello/test-ivy-extends.xml ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/parser/xml/foo%2Fbar/hello/test-ivy-extends.xml b/test/java/org/apache/ivy/plugins/parser/xml/foo%2Fbar/hello/test-ivy-extends.xml deleted file mode 100644 index fca2360..0000000 --- a/test/java/org/apache/ivy/plugins/parser/xml/foo%2Fbar/hello/test-ivy-extends.xml +++ /dev/null @@ -1,25 +0,0 @@ -<!-- - ~ 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. - --> -<ivy-module version="1.0"> - <info organisation="myorg" - module="mymodule"> - <extends organisation="myorg" module="myparent" revision="1.0.0" location="../../foo%2Fbar/parent-ivy.xml"/> - </info> - <configurations> - <conf name="conf2" visibility="private"/> - </configurations> -</ivy-module> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/c8712654/test/java/org/apache/ivy/plugins/parser/xml/foo%2Fbar/parent-ivy.xml ---------------------------------------------------------------------- diff --git a/test/java/org/apache/ivy/plugins/parser/xml/foo%2Fbar/parent-ivy.xml b/test/java/org/apache/ivy/plugins/parser/xml/foo%2Fbar/parent-ivy.xml deleted file mode 100644 index b54dc92..0000000 --- a/test/java/org/apache/ivy/plugins/parser/xml/foo%2Fbar/parent-ivy.xml +++ /dev/null @@ -1,27 +0,0 @@ -<!-- - ~ 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. - --> -<ivy-module version="1.0"> - <info organisation="myorg" - module="myparent" - revision="1.0.0"> - <description>Parent module description.</description> - </info> - <configurations> - <conf name="parent-conf1"/> - <conf name="parent-conf2" visibility="public"/> - </configurations> -</ivy-module>
