Skip to content
Closed
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 @@ -755,33 +755,22 @@ private void populateCollectRequest( CollectRequest collectRequest, Task task, R
Model model = dependencies.getPom().getModel( task );
for ( org.apache.maven.model.Dependency dep : model.getDependencies() )
{
Dependency dependency = new Dependency();
dependency.setArtifactId( dep.getArtifactId() );
dependency.setClassifier( dep.getClassifier() );
dependency.setGroupId( dep.getGroupId() );
dependency.setScope( dep.getScope() );
dependency.setType( dep.getType() );
dependency.setVersion( dep.getVersion() );
Dependency dependency = toDependency( dep, task );
if ( ids.contains( dependency.getVersionlessKey() ) )
{
project.log( "Ignoring dependency " + dependency.getVersionlessKey() + " from " + model.getId()
+ ", already declared locally", Project.MSG_VERBOSE );
continue;
}
if ( dep.getSystemPath() != null && dep.getSystemPath().length() > 0 )
{
dependency.setSystemPath( task.getProject().resolveFile( dep.getSystemPath() ) );
}
for ( org.apache.maven.model.Exclusion exc : dep.getExclusions() )
collectRequest.addDependency( ConverterUtils.toDependency( dependency, globalExclusions, session ) );
}
if ( model.getDependencyManagement() != null )
{
for ( org.apache.maven.model.Dependency dep : model.getDependencyManagement().getDependencies() )
{
Exclusion exclusion = new Exclusion();
exclusion.setGroupId( exc.getGroupId() );
exclusion.setArtifactId( exc.getArtifactId() );
exclusion.setClassifier( "*" );
exclusion.setExtension( "*" );
dependency.addExclusion( exclusion );
Dependency dependency = toDependency( dep, task );
collectRequest.addManagedDependency( ConverterUtils.toDependency( dependency, globalExclusions, session ) );
}
collectRequest.addDependency( ConverterUtils.toDependency( dependency, globalExclusions, session ) );
}
}

Expand All @@ -801,6 +790,31 @@ private void populateCollectRequest( CollectRequest collectRequest, Task task, R
}
}

private Dependency toDependency( org.apache.maven.model.Dependency dep, Task task )
{
Dependency dependency = new Dependency();
dependency.setArtifactId( dep.getArtifactId() );
dependency.setClassifier( dep.getClassifier() );
dependency.setGroupId( dep.getGroupId() );
dependency.setScope( dep.getScope() );
dependency.setType( dep.getType() );
dependency.setVersion( dep.getVersion() );
if ( dep.getSystemPath() != null && dep.getSystemPath().length() > 0 )
{
dependency.setSystemPath( task.getProject().resolveFile( dep.getSystemPath() ) );
}
for ( org.apache.maven.model.Exclusion exc : dep.getExclusions() )
{
Exclusion exclusion = new Exclusion();
exclusion.setGroupId( exc.getGroupId() );
exclusion.setArtifactId( exc.getArtifactId() );
exclusion.setClassifier( "*" );
exclusion.setExtension( "*" );
dependency.addExclusion( exclusion );
}
return dependency;
}

private List<Dependency> readDependencies( File file )
{
List<Dependency> dependencies = new ArrayList<Dependency>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* 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
Expand Down Expand Up @@ -76,14 +76,31 @@ public void testResolveCustomFileLayout()
new File( dir, "org.eclipse.aether/aether-api/org/eclipse/aether/jar" ).exists() );
}

public void testResolvePomWithManagedDeps()
{
executeTarget( "testResolvePomWithManagedDeps" );

String prop = getProject().getProperty( "test.resolve.path.org.apache.maven.resolver:maven-resolver-api:jar" );
assertThat( "maven-resolver-api was not resolved to managed version", prop.replace( '\\', '/' ),
endsWith( "org/apache/maven/resolver/maven-resolver-api/1.4.1/maven-resolver-api-1.4.1.jar" ) );
}

public void testResolvePomWithScopedAndManagement()
{
executeTarget( "testResolvePomWithScopedAndManagement" );

assertNull( getProject().getProperty( "test.resolve.path.org.apache.maven.resolver:maven-resolver-util:jar" ) );
assertNull( getProject().getProperty( "test.resolve.path.org.apache.maven.resolver:maven-resolver-api:jar" ) );
}

public void testResolveAttachments()
throws IOException
{
File dir = new File( BUILD_DIR, "resolve-attachments" );
executeTarget( "testResolveAttachments" );

File jdocDir = new File(dir, "javadoc");

assertThat( "aether-api-javadoc was not saved with custom file layout",
new File( jdocDir, "org.eclipse.aether-aether-api-javadoc.jar" ).exists() );

Expand Down
18 changes: 18 additions & 0 deletions src/test/resources/ant/Resolve/ant.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@
</repo:resolve>
</target>

<target name="testResolvePomWithManagedDeps">
<repo:resolve>
<dependencies>
<pom file="${project.dir}/with-dependency-management.pom"/>
</dependencies>
<properties prefix="test.resolve.path" classpath="runtime"/>
</repo:resolve>
</target>

<target name="testResolvePomWithScopedAndManagement">
<repo:resolve>
<dependencies>
<pom file="${project.dir}/with-scoped-and-management.pom"/>
</dependencies>
<properties prefix="test.resolve.path" classpath="runtime"/>
</repo:resolve>
</target>

<target name="testResolveAttachments">
<repo:resolve>
<dependencies>
Expand Down
48 changes: 48 additions & 0 deletions src/test/resources/ant/Resolve/with-dependency-management.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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>

<groupId>test</groupId>
<artifactId>dummy</artifactId>
<version>0.1-SNAPSHOT</version>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
<version>1.4.1</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-util</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
</project>
50 changes: 50 additions & 0 deletions src/test/resources/ant/Resolve/with-scoped-and-management.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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>

<groupId>test</groupId>
<artifactId>dummy</artifactId>
<version>0.1-SNAPSHOT</version>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
<version>1.4.1</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-util</artifactId>
<version>1.4.1</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>