elharo commented on code in PR #12:
URL:
https://github.com/apache/maven-dependency-plugin/pull/12#discussion_r1798284616
##########
src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java:
##########
@@ -80,8 +93,25 @@ protected void setUp()
DefaultRepositorySystemSession repoSession =
(DefaultRepositorySystemSession) session.getRepositorySession();
repoSession.setLocalRepositoryManager( new
SimpleLocalRepositoryManager( stubFactory.getWorkingDir() ) );
+
+ artifactHandlerManager = new DefaultArtifactHandlerManager();
+
+ Map<String, ArtifactHandler> handlerMap = new HashMap<>();
+ handlerMap.put("", new DefaultArtifactHandler(""));
+ handlerMap.put("jar", new DefaultArtifactHandler("jar"));
+ artifactHandlerManager.addHandlers(handlerMap);
+ }
+
+ @Override
+ protected void tearDown()
+ {
+ super.tearDown();
Review Comment:
this comes last, not first
##########
src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java:
##########
@@ -189,6 +202,105 @@ protected List<ArtifactItem> getProcessedArtifactItems(
ProcessArtifactItemsRequ
return artifactItems;
}
+ /**
+ * If the artifact item has a version range, rather than a version, this
+ * method attempts to resolve this range by inspecting the list of
resolved dependencies
+ * in the project for a match, before using the maven dependency resolver
to resolve
+ * the range.
+ *
+ * If the dependency can be found and the version fits the artifact item's
range
+ * then the artifact item is updated with the found version.
+ *
+ * If the dependency is not found or the range does not match, then the
version
+ * is not changed.
+ *
+ * @param artifactItem The artifact item to update, if required.
Review Comment:
nit: the artifact item to update, if required
per oracle javadoc conventions
##########
src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyResolverStub.java:
##########
@@ -0,0 +1,98 @@
+package org.apache.maven.plugins.dependency.testUtils.stubs;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
+import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
+import
org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
+import
org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
+
+/**
+ * A very simple stub to use for whiteboxing the a Maven DependencyResolver
+ * class.
+ */
+public class DependencyResolverStub implements DependencyResolver {
+
+ private Map<String, Artifact> coordCache = new HashMap<>();
+
+ public void addDependableCoordinateLookup(
+ final DependableCoordinate coord,
+ final Artifact artifact )
+ {
+ coordCache.put( coord.toString(), artifact );
+ }
+
+ @Override
+ public Iterable<ArtifactResult> resolveDependencies(
+ final ProjectBuildingRequest buildingRequest,
+ final DependableCoordinate coordinate,
+ final TransformableFilter filter ) throws
DependencyResolverException
+ {
+
+
+ if ( coordCache.get( coordinate.toString() ) != null ) {
+ ArtifactResult result = new ArtifactResult()
+ {
+
+ @Override
+ public Artifact getArtifact()
+ {
+ // TODO Auto-generated method stub
Review Comment:
remove comment
##########
pom.xml:
##########
@@ -30,7 +30,7 @@ under the License.
</parent>
<artifactId>maven-dependency-plugin</artifactId>
- <version>3.1.2-SNAPSHOT</version>
+ <version>3.1.1.alehane-SNAPSHOT</version>
Review Comment:
nope
##########
src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyResolverStub.java:
##########
@@ -0,0 +1,98 @@
+package org.apache.maven.plugins.dependency.testUtils.stubs;
+
Review Comment:
above package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]