You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2012/08/19 17:37:26 UTC
svn commit: r1374774 - in /ant/ivy/core/trunk: ./
src/java/org/apache/ivy/plugins/parser/xml/
test/java/org/apache/ivy/core/resolve/ test/repositories/IVY-1347/
test/repositories/IVY-1347/childone/
test/repositories/IVY-1347/childone/childtwo/ test/rep...
Author: maartenc
Date: Sun Aug 19 15:37:25 2012
New Revision: 1374774
URL: http://svn.apache.org/viewvc?rev=1374774&view=rev
Log:
- FIX: Unnecessary warning when parent ivy.xml is not found (IVY-1346)
- FIX: StackOverflowError when using <extends> and ../ivy.xml is not the parent ivy.xml (IVY-1437)
Added:
ant/ivy/core/trunk/test/repositories/IVY-1347/
ant/ivy/core/trunk/test/repositories/IVY-1347/childone/
ant/ivy/core/trunk/test/repositories/IVY-1347/childone/childtwo/
ant/ivy/core/trunk/test/repositories/IVY-1347/childone/childtwo/ivy.xml
ant/ivy/core/trunk/test/repositories/IVY-1347/childone/ivy.xml
ant/ivy/core/trunk/test/repositories/IVY-1347/ivysettings.xml
ant/ivy/core/trunk/test/repositories/IVY-1347/repo/
ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/
ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/
ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/1.0/
ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/1.0/ivys/
ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/1.0/ivys/ivy.xml
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1374774&r1=1374773&r2=1374774&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Sun Aug 19 15:37:25 2012
@@ -130,6 +130,8 @@ for detailed view of each issue, please
trunk
=====================================
+- FIX: Unnecessary warning when parent ivy.xml is not found (IVY-1346)
+- FIX: StackOverflowError when using <extends> and ../ivy.xml is not the parent ivy.xml (IVY-1437)
- FIX: NullPointerExeption in AbstractOSGiResolver (IVY-1343) (thanks to Thomas Kurpick)
- FIX: Delivered ivy descriptor inconsistent with resolve report / retrieve and other post-resolve actions (IVY-1300) (thanks to Ed Burcher)
- FIX: The Updatesite resolver is downloading Eclipse features instead of Eclipse bundle/plugin
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java?rev=1374774&r1=1374773&r2=1374774&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java Sun Aug 19 15:37:25 2012
@@ -21,10 +21,11 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.text.ParseException;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
@@ -70,7 +71,8 @@ import org.apache.ivy.plugins.parser.Par
import org.apache.ivy.plugins.repository.Resource;
import org.apache.ivy.plugins.repository.url.URLResource;
import org.apache.ivy.plugins.resolver.DependencyResolver;
-import org.apache.ivy.plugins.resolver.URLResolver;
+import org.apache.ivy.plugins.resolver.FileSystemResolver;
+import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.XMLHelper;
import org.apache.ivy.util.extendable.ExtendableItemHelper;
@@ -404,15 +406,15 @@ public class XmlModuleDescriptorParser e
//check on filesystem based on location attribute (for dev ONLY)
try {
- checkParentModuleOnFilesystem(location, parentMrid);
+ DependencyResolver parentResolver = checkParentModuleOnFilesystem(location, parentMrid);
+ if (parentResolver != null) {
+ parent = resolveParentFromModuleInheritanceRepository(parentResolver, parentMrid);
+ }
} catch (IOException e) {
Message.warn("Unable to parse included ivy file " + location + ": "
+ e.getMessage());
}
- // Resolve parent module descriptor from module inheritance repository
- parent = resolveParentFromModuleInheritanceRepository(parentMrid);
-
// if not found, tries to resolve using repositories
if (parent == null) {
try {
@@ -596,28 +598,30 @@ public class XmlModuleDescriptorParser e
* @throws IOException
* @throws ParseException
*/
- protected void checkParentModuleOnFilesystem(String location, ModuleRevisionId parentMrid) throws IOException, ParseException {
- IvyContext ivyContext = IvyContext.getContext();
- File file = new File(location);
- URL url = null;
- if (file.isAbsolute()) {
- url = getSettings().getRelativeUrlResolver().getURL(descriptorURL,
- file.getAbsolutePath(), location);
- } else {
- url = getSettings().getRelativeUrlResolver().getURL(descriptorURL, location);
+ protected DependencyResolver checkParentModuleOnFilesystem(String location, ModuleRevisionId parentMrid) throws IOException {
+ if (!"file".equals(descriptorURL.getProtocol())) {
+ return null;
}
- // Is parent module reachable using location attribute?
- if (url.openConnection().getContentLength() > 0) {
- String urlString = url.toExternalForm();
- if (!ivyContext.getSettings().hasResolver(getModuleInheritanceRepositoryParentResolverName(parentMrid))) {
- Message.debug("Registering parent module into module inheritance repository map. Parent module location: " + urlString);
- URLResolver parentModuleResolver = new URLResolver();
- parentModuleResolver.setName(getModuleInheritanceRepositoryParentResolverName(parentMrid));
- parentModuleResolver.addIvyPattern(url.toExternalForm());
- // Do we even need to be adding this resolver to the Ivy settings considering that it's being placed in the map and not being used elsewhere?
- ivyContext.getSettings().addResolver(parentModuleResolver);
+
+ File file = FileUtil.normalize(location);
+ if (!file.isAbsolute()) {
+ URL url = new URL(descriptorURL, location);
+ try {
+ file = FileUtil.normalize(new File(new URI(url.toExternalForm())).getAbsolutePath());
+ } catch (URISyntaxException e) {
+ file = FileUtil.normalize(new File(url.getPath()).getAbsolutePath());
}
}
+
+ if (!file.exists()) {
+ return null;
+ }
+
+ FileSystemResolver parentModuleResolver = new FileSystemResolver();
+ parentModuleResolver.setName(getModuleInheritanceRepositoryParentResolverName(parentMrid));
+ parentModuleResolver.addIvyPattern(file.getAbsolutePath());
+ parentModuleResolver.setSettings(IvyContext.getContext().getSettings());
+ return parentModuleResolver;
}
/**
@@ -654,7 +658,7 @@ public class XmlModuleDescriptorParser e
* @return a {@link ModuleDescriptor} if found. Return null if no {@link ModuleDescriptor} was found
* @throws ParseException
*/
- protected ModuleDescriptor resolveParentFromModuleInheritanceRepository(ModuleRevisionId parentMrid) throws ParseException {
+ protected ModuleDescriptor resolveParentFromModuleInheritanceRepository(DependencyResolver resolver, ModuleRevisionId parentMrid) throws ParseException {
Message.debug("Trying to resolve included ivy file from module inheritance repository " );
DependencyDescriptor dd = new DefaultDependencyDescriptor(parentMrid, true);
ResolveEngine engine = IvyContext.getContext().getIvy().getResolveEngine();
@@ -663,14 +667,6 @@ public class XmlModuleDescriptorParser e
options.setDownload(false);
ResolveData data = new ResolveData(engine, options);
- IvySettings settings = IvyContext.getContext().getSettings();
- String resolverName = getModuleInheritanceRepositoryParentResolverName(parentMrid);
- if (!settings.hasResolver(resolverName)) {
- // The parent resolver will not exist if its dev-only filesystem path hasn't been specified via the location attribute of the extends element.
- return null;
- }
-
- DependencyResolver resolver = settings.getResolver(resolverName);
dd = NameSpaceHelper.toSystem(dd, getSettings().getContextNamespace());
ResolvedModuleRevision otherModule = resolver.getDependency(dd, data);
if (otherModule != null) {
Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=1374774&r1=1374773&r2=1374774&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java Sun Aug 19 15:37:25 2012
@@ -44,6 +44,7 @@ import org.apache.ivy.core.deliver.Deliv
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.DefaultArtifact;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ExtendsDescriptor;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
@@ -3398,6 +3399,24 @@ public class ResolveTest extends TestCas
assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "badArtifact", "1.0.0.m4", extra)));
}
+ public void testIVY1347() throws Exception {
+ Ivy ivy = new Ivy();
+ ivy.configure(new File("test/repositories/IVY-1347/ivysettings.xml"));
+ ivy.getSettings().setDefaultCache(cache);
+
+ ResolveReport rr = ivy.resolve(new File("test/repositories/IVY-1347/childone/childtwo/ivy.xml").toURI().toURL(),
+ getResolveOptions(new String[] {"*"}));
+ ModuleDescriptor md = rr.getModuleDescriptor();
+ assertNotNull(md);
+
+ ExtendsDescriptor[] parents = md.getInheritedDescriptors();
+ assertNotNull(parents);
+ assertEquals(1, parents.length);
+
+ ModuleRevisionId parent = parents[0].getParentRevisionId();
+ assertEquals(ModuleRevisionId.newInstance("foo", "parent", "1.0"), parent);
+ }
+
public void testIVY999() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-999/ivysettings.xml"));
Added: ant/ivy/core/trunk/test/repositories/IVY-1347/childone/childtwo/ivy.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1347/childone/childtwo/ivy.xml?rev=1374774&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1347/childone/childtwo/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1347/childone/childtwo/ivy.xml Sun Aug 19 15:37:25 2012
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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="2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
+ <info organisation="foo" module="childtwo" revision="1.0" status="integration">
+ <extends organisation="foo" module="parent" revision="1.0"/>
+ </info>
+ <publications>
+ <artifact name="child" type="jar" ext="jar"/>
+ </publications>
+</ivy-module>
+
Added: ant/ivy/core/trunk/test/repositories/IVY-1347/childone/ivy.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1347/childone/ivy.xml?rev=1374774&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1347/childone/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1347/childone/ivy.xml Sun Aug 19 15:37:25 2012
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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="2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
+ <info organisation="foo" module="childone" revision="1.0" status="integration">
+ <extends organisation="foo" module="parent" revision="1.0"/>
+ </info>
+ <publications>
+ <artifact name="child" type="jar" ext="jar"/>
+ </publications>
+</ivy-module>
+
Added: ant/ivy/core/trunk/test/repositories/IVY-1347/ivysettings.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1347/ivysettings.xml?rev=1374774&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1347/ivysettings.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1347/ivysettings.xml Sun Aug 19 15:37:25 2012
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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-settings>
+
+ <settings defaultResolver="default" circularDependencyStrategy="error" defaultConflictManager="latest-revision" validate="false" />
+
+ <resolvers>
+ <filesystem name="default" local="true" checkmodified="true">
+ <ivy pattern="${ivy.settings.dir}/repo/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" />
+ <artifact pattern="${ivy.settings.dir}/repo/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" />
+ </filesystem>
+ </resolvers>
+
+</ivy-settings>
Added: ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/1.0/ivys/ivy.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/1.0/ivys/ivy.xml?rev=1374774&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/1.0/ivys/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1347/repo/foo/parent/1.0/ivys/ivy.xml Sun Aug 19 15:37:25 2012
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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="2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
+ <info organisation="foo" module="parent" revision="1.0" status="integration"/>
+</ivy-module>