FIX: Maven2: resolve failure when parent has <dependencyManagement> with dependency in 'import' scope (IVY-1376) (merged from trunk)

git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/branches/2.3.x@1419772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Maarten Coene 2012-12-10 21:13:43 +00:00
parent 0393da7c84
commit e73f1b0069
11 changed files with 195 additions and 13 deletions

View File

@ -128,6 +128,10 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br
Sven Zethelius
Aleksey Zhukov
2.3.x
=====================================
- FIX: Maven2: resolve failure when parent has <dependencyManagement> with dependency in 'import' scope (IVY-1376)
2.3.0-rc2
=====================================
- DOCUMENTATION: Documentation and Implementation mismatch of makepom (IVY-1383) (thanks to Thomas Kurpick)

View File

@ -252,7 +252,13 @@ public final class PomModuleDescriptorParser implements ModuleDescriptorParser {
// add dependency management info from imported module
List depMgt = PomModuleDescriptorBuilder.getDependencyManagements(importDescr);
for (Iterator it2 = depMgt.iterator(); it2.hasNext();) {
mdBuilder.addDependencyMgt((PomDependencyMgt) it2.next());
PomDependencyMgt importedDepMgt = (PomDependencyMgt) it2.next();
mdBuilder.addDependencyMgt(new DefaultPomDependencyMgt(
importedDepMgt.getGroupId(),
importedDepMgt.getArtifactId(),
importedDepMgt.getVersion(),
importedDepMgt.getScope(),
importedDepMgt.getExcludedModules()));
}
} else {
throw new IOException("Impossible to import module for " + res.getName() + "."

View File

@ -4583,6 +4583,33 @@ public class ResolveTest extends TestCase {
"test4", "jar", "jar").exists());
}
public void testResolveMaven2ParentPomDependencyManagementWithImport() throws Exception {
// IVY-1376
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/parentPom/ivysettings.xml"));
ivy.getSettings().setDefaultResolver("parentChain");
ResolveReport report = ivy.resolve(new File(
"test/repositories/parentPom/org/apache/dm/test/3.0/test-3.0.pom").toURL(),
getResolveOptions(new String[] {"*"}));
assertNotNull(report);
//test the report to make sure the right dependencies are listed
List dependencies = report.getDependencies();
assertFalse(report.hasError());
assertEquals(2, dependencies.size());
IvyNode ivyNode;
ivyNode = (IvyNode) dependencies.get(0);
assertNotNull(ivyNode);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.dm", "test5", "2.0");
assertEquals(mrid, ivyNode.getId());
assertTrue(getIvyFileInCache(
ModuleRevisionId.newInstance("org.apache.dm", "test5", "2.0")).exists());
assertTrue(getArchiveFileInCache(ivy, "org.apache.dm", "test5", "2.0",
"test5", "jar", "jar").exists());
}
public void testResolveMaven2Snapshot1() throws Exception {
// test case for IVY-501
// here we test maven SNAPSHOT versions handling,

View File

@ -28,25 +28,27 @@
<artifactId>parent</artifactId>
<name>Test parsing parent POM</name>
<version>2.0</version>
<properties>
<test4.version>1.0</test4.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.dm</groupId>
<artifactId>test2</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dm</groupId>
<artifactId>test4</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.dm</groupId>
<artifactId>test2</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dm</groupId>
<artifactId>test4</artifactId>
<version>${test4.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependencies>
<dependency>
<groupId>org.apache.dm</groupId>
<artifactId>test3</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -23,6 +23,9 @@
<artifactId>parent2</artifactId>
<name>Test parsing parent POM</name>
<version>1.0</version>
<properties>
<test3.version>1.0</test3.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
@ -33,7 +36,13 @@
<dependency>
<groupId>org.apache.dm</groupId>
<artifactId>test3</artifactId>
<version>${test3.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dm</groupId>
<artifactId>parent3</artifactId>
<version>1.0</version>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

View File

@ -0,0 +1,38 @@
<?xml version="1.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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.dm</groupId>
<artifactId>parent3</artifactId>
<name>Test parsing parent POM</name>
<version>1.0</version>
<properties>
<test5.version>2.0</test5.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.dm</groupId>
<artifactId>test5</artifactId>
<version>${test5.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,42 @@
<?xml version="1.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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parent</artifactId>
<groupId>org.apache.dm</groupId>
<version>2.0</version>
</parent>
<groupId>org.apache.dm</groupId>
<artifactId>test</artifactId>
<name>Test parsing parent POM</name>
<version>3.0</version>
<url>http://ant.apache.org/ivy</url>
<organization>
<name>Apache</name>
<url>http://www.apache.org/</url>
</organization>
<dependencies>
<dependency>
<groupId>org.apache.dm</groupId>
<artifactId>test5</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,26 @@
<?xml version="1.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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.dm</groupId>
<artifactId>test5</artifactId>
<name>Test parsing parent POM</name>
<version>1.0</version>
</project>

View File

@ -0,0 +1,26 @@
<?xml version="1.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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.dm</groupId>
<artifactId>test5</artifactId>
<name>Test parsing parent POM</name>
<version>2.0</version>
</project>