Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,33 @@ private void populateCollectRequest(

if (dependencies.getPom() != null) {
Model model = dependencies.getPom().getModel(task);
if (model.getDependencyManagement() != null) {
for (org.apache.maven.model.Dependency manDep :
model.getDependencyManagement().getDependencies()) {
Dependency dependency = new Dependency();
dependency.setArtifactId(manDep.getArtifactId());
dependency.setClassifier(manDep.getClassifier());
dependency.setGroupId(manDep.getGroupId());
dependency.setScope(manDep.getScope());
dependency.setType(manDep.getType());
dependency.setVersion(manDep.getVersion());
if (manDep.getSystemPath() != null
&& !manDep.getSystemPath().isEmpty()) {
dependency.setSystemPath(task.getProject().resolveFile(manDep.getSystemPath()));
}
for (org.apache.maven.model.Exclusion exc : manDep.getExclusions()) {
Exclusion exclusion = new Exclusion();
exclusion.setGroupId(exc.getGroupId());
exclusion.setArtifactId(exc.getArtifactId());
exclusion.setClassifier("*");
exclusion.setExtension("*");
dependency.addExclusion(exclusion);
}
collectRequest.addManagedDependency(
ConverterUtils.toDependency(dependency, globalExclusions, session));
}
}

for (org.apache.maven.model.Dependency dep : model.getDependencies()) {
Dependency dependency = new Dependency();
dependency.setArtifactId(dep.getArtifactId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,23 @@ public void testResolveResourceCollectionOnly() {
file = (FileResource) it.next();
assertThat(file.getFile().getName(), is("aether-api-0.9.0.v20140226.jar"));
}

@Test
public void testResolveTransitiveDependencyManagement() {
executeTarget("testResolveTransitiveDependencyManagement");

String prop = getProject().getProperty("test.resolve.path.org.slf4j:slf4j-api:jar");
assertThat("slf4j-api was not resolved as a property", prop, notNullValue());
assertThat(
"slf4j-api was not resolved to default local repository",
prop,
allOf(containsString("slf4j-api"), endsWith("slf4j-api-2.0.6.jar")));

prop = getProject().getProperty("test.resolve.path.org.apiguardian:apiguardian-api:jar");
assertThat("apiguardian-api was not resolved as a property", prop, notNullValue());
assertThat(
"apiguardian-api was not resolved to default local repository",
prop,
allOf(containsString("apiguardian-api"), endsWith("apiguardian-api-1.1.1.jar")));
}
}
7 changes: 7 additions & 0 deletions src/test/resources/ant/Resolve/ant.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,11 @@
</repo:resolve>
</target>

<target name="testResolveTransitiveDependencyManagement">
<repo:pom file="${project.dir}/transitive-depmgt-pom.xml"/>
<repo:resolve>
<properties prefix="test.resolve.path" classpath="compile"/>
</repo:resolve>
</target>

</project>
82 changes: 82 additions & 0 deletions src/test/resources/ant/Resolve/transitive-depmgt-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.sonatype.forge</groupId>
<artifactId>forge-parent</artifactId>
<version>10</version>
</parent>

<groupId>org.eclipse.aether</groupId>
<artifactId>aether-ant-tasks</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<!--
Transitive Dependency Management POM test

This test does two things:
- depends on slf4j-simple:2.0.7 but overrides its transitive dep slf4j-api to version 2.0.6
- overrides apiguardian-api to version 1.1.1 in depMgt
- uses Junit BOM, that would like to use apiguardian-api 1.1.2
-->

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.apiguardian</groupId>
<artifactId>apiguardian-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>