You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/04/12 16:21:18 UTC
[maven-resolver-ant-tasks] branch MRESOLVER-98 created (now 6406b9f)
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch MRESOLVER-98
in repository https://gitbox.apache.org/repos/asf/maven-resolver-ant-tasks.git.
at 6406b9f test: add test case testResolvePomWithScopedAndManagement (failed)
This branch includes the following new commits:
new ca8c131 [MRESOLVER-98] resolver ant task doesn't obey dependencyManagement
new 6406b9f test: add test case testResolvePomWithScopedAndManagement (failed)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[maven-resolver-ant-tasks] 01/02: [MRESOLVER-98] resolver ant task
doesn't obey dependencyManagement
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MRESOLVER-98
in repository https://gitbox.apache.org/repos/asf/maven-resolver-ant-tasks.git
commit ca8c1311c81a5da50d01368f56563a990df6bc41
Author: William Leung <wi...@gmail.com>
AuthorDate: Mon Mar 2 12:47:17 2020 +0800
[MRESOLVER-98] resolver ant task doesn't obey dependencyManagement
Closes #2
---
pom.xml | 4 +-
.../maven/resolver/internal/ant/AntRepoSys.java | 52 ++++++++++++++--------
.../internal/ant/AntSettingsDecryptorFactory.java | 21 ++-------
.../maven/resolver/internal/ant/ResolveTest.java | 17 +++++--
src/test/resources/ant/Resolve/ant.xml | 9 ++++
.../ant/Resolve/with-dependency-management.pom | 48 ++++++++++++++++++++
6 files changed, 108 insertions(+), 43 deletions(-)
diff --git a/pom.xml b/pom.xml
index a52b02c..acb8a15 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,8 +61,8 @@
</distributionManagement>
<properties>
- <mavenVersion>3.5.0</mavenVersion>
- <resolverVersion>1.3.3</resolverVersion>
+ <mavenVersion>3.6.3</mavenVersion>
+ <resolverVersion>1.4.1</resolverVersion>
<antVersion>1.8.4</antVersion>
<javaVersion>7</javaVersion>
<maven.site.path>resolver-archives/resolver-ant-tasks-LATEST</maven.site.path>
diff --git a/src/main/java/org/apache/maven/resolver/internal/ant/AntRepoSys.java b/src/main/java/org/apache/maven/resolver/internal/ant/AntRepoSys.java
index 9242855..e2848b1 100644
--- a/src/main/java/org/apache/maven/resolver/internal/ant/AntRepoSys.java
+++ b/src/main/java/org/apache/maven/resolver/internal/ant/AntRepoSys.java
@@ -678,33 +678,22 @@ public class AntRepoSys
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 ) );
}
}
@@ -724,6 +713,31 @@ public class AntRepoSys
}
}
+ 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>();
diff --git a/src/main/java/org/apache/maven/resolver/internal/ant/AntSettingsDecryptorFactory.java b/src/main/java/org/apache/maven/resolver/internal/ant/AntSettingsDecryptorFactory.java
index 39ef960..bfa2e07 100644
--- a/src/main/java/org/apache/maven/resolver/internal/ant/AntSettingsDecryptorFactory.java
+++ b/src/main/java/org/apache/maven/resolver/internal/ant/AntSettingsDecryptorFactory.java
@@ -8,9 +8,9 @@ package org.apache.maven.resolver.internal.ant;
* 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
@@ -19,8 +19,6 @@ package org.apache.maven.resolver.internal.ant;
* under the License.
*/
-import java.lang.reflect.Field;
-
import org.apache.maven.settings.crypto.DefaultSettingsDecrypter;
/**
@@ -32,20 +30,7 @@ class AntSettingsDecryptorFactory
{
AntSecDispatcher secDispatcher = new AntSecDispatcher();
- DefaultSettingsDecrypter decrypter = new DefaultSettingsDecrypter();
-
- try
- {
- Field field = decrypter.getClass().getDeclaredField( "securityDispatcher" );
- field.setAccessible( true );
- field.set( decrypter, secDispatcher );
- }
- catch ( Exception e )
- {
- throw new IllegalStateException( e );
- }
-
- return decrypter;
+ return new DefaultSettingsDecrypter( secDispatcher );
}
}
diff --git a/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java b/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java
index a736a74..ab560fd 100644
--- a/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java
+++ b/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.resolver.internal.ant;
* 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
@@ -76,14 +76,23 @@ public class ResolveTest
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 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() );
diff --git a/src/test/resources/ant/Resolve/ant.xml b/src/test/resources/ant/Resolve/ant.xml
index 12b4f34..b32b05b 100644
--- a/src/test/resources/ant/Resolve/ant.xml
+++ b/src/test/resources/ant/Resolve/ant.xml
@@ -68,6 +68,15 @@
</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="testResolveAttachments">
<repo:resolve>
<dependencies>
diff --git a/src/test/resources/ant/Resolve/with-dependency-management.pom b/src/test/resources/ant/Resolve/with-dependency-management.pom
new file mode 100644
index 0000000..759b540
--- /dev/null
+++ b/src/test/resources/ant/Resolve/with-dependency-management.pom
@@ -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>
[maven-resolver-ant-tasks] 02/02: test: add test case
testResolvePomWithScopedAndManagement (failed)
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MRESOLVER-98
in repository https://gitbox.apache.org/repos/asf/maven-resolver-ant-tasks.git
commit 6406b9f31b5094b354fda9ec6b4f007adccbc4d6
Author: William Leung <wi...@gmail.com>
AuthorDate: Tue Mar 3 17:34:45 2020 +0800
test: add test case testResolvePomWithScopedAndManagement (failed)
---
.../maven/resolver/internal/ant/ResolveTest.java | 8 ++++
src/test/resources/ant/Resolve/ant.xml | 9 ++++
.../ant/Resolve/with-scoped-and-management.pom | 50 ++++++++++++++++++++++
3 files changed, 67 insertions(+)
diff --git a/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java b/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java
index ab560fd..17638b7 100644
--- a/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java
+++ b/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java
@@ -85,6 +85,14 @@ public class ResolveTest
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
{
diff --git a/src/test/resources/ant/Resolve/ant.xml b/src/test/resources/ant/Resolve/ant.xml
index b32b05b..9b3767a 100644
--- a/src/test/resources/ant/Resolve/ant.xml
+++ b/src/test/resources/ant/Resolve/ant.xml
@@ -77,6 +77,15 @@
</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>
diff --git a/src/test/resources/ant/Resolve/with-scoped-and-management.pom b/src/test/resources/ant/Resolve/with-scoped-and-management.pom
new file mode 100644
index 0000000..c51844c
--- /dev/null
+++ b/src/test/resources/ant/Resolve/with-scoped-and-management.pom
@@ -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>