You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/08/27 10:14:33 UTC

[GitHub] [maven-dependency-plugin] slawekjaranowski commented on a diff in pull request #233: [MDEP-782] - Add ability to strip type

slawekjaranowski commented on code in PR #233:
URL: https://github.com/apache/maven-dependency-plugin/pull/233#discussion_r956565164


##########
src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractFromDependenciesMojo.java:
##########
@@ -45,6 +45,12 @@
     @Parameter( property = "mdep.stripVersion", defaultValue = "false" )
     protected boolean stripVersion = false;
 
+    /**
+     * Strip artifact type during copy
+     */
+    @Parameter( property = "mdep.stripType", defaultValue = "false" )

Review Comment:
   Please add `@since 3.4.0`



##########
src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java:
##########
@@ -373,7 +373,50 @@ public void testSubPerArtifactAndTypeRemoveVersion()
         for ( Artifact artifact : artifacts )
         {
             String fileName = DependencyUtil.getFormattedFileName( artifact, true );
-            File folder = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, true,
+            File folder = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, true, false,
+                                                                      mojo.outputDirectory, artifact );
+            File file = new File( folder, fileName );
+            assertTrue( file.exists() );
+        }
+    }
+
+    public void testSubPerArtifactRemoveType()
+        throws Exception
+    {
+        mojo.useSubDirectoryPerArtifact = true;
+        mojo.stripType = true;
+
+        mojo.execute();
+
+        Set<Artifact> artifacts = mojo.getProject().getArtifacts();
+        for ( Artifact artifact : artifacts )
+        {
+            // TODO fix test
+            String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+            File folder = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, false, true,
+                mojo.outputDirectory, artifact );
+            File file = new File( folder, fileName );
+            assertTrue( file.exists() );
+        }
+    }
+
+    public void testSubPerArtifactAndTypeRemoveType()
+        throws Exception
+    {
+        mojo.getProject().setArtifacts( stubFactory.getTypedArtifacts() );
+        mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() );
+        mojo.useSubDirectoryPerArtifact = true;
+        mojo.useSubDirectoryPerType = true;
+        mojo.stripType = true;
+
+        mojo.execute();
+
+        Set<Artifact> artifacts = mojo.getProject().getArtifacts();
+        for ( Artifact artifact : artifacts )
+        {
+            // TODO fix test

Review Comment:
   ?



##########
src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java:
##########
@@ -373,7 +373,50 @@ public void testSubPerArtifactAndTypeRemoveVersion()
         for ( Artifact artifact : artifacts )
         {
             String fileName = DependencyUtil.getFormattedFileName( artifact, true );
-            File folder = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, true,
+            File folder = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, true, false,
+                                                                      mojo.outputDirectory, artifact );
+            File file = new File( folder, fileName );
+            assertTrue( file.exists() );
+        }
+    }
+
+    public void testSubPerArtifactRemoveType()
+        throws Exception
+    {
+        mojo.useSubDirectoryPerArtifact = true;
+        mojo.stripType = true;
+
+        mojo.execute();
+
+        Set<Artifact> artifacts = mojo.getProject().getArtifacts();
+        for ( Artifact artifact : artifacts )
+        {
+            // TODO fix test
+            String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+            File folder = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, false, true,
+                mojo.outputDirectory, artifact );
+            File file = new File( folder, fileName );
+            assertTrue( file.exists() );

Review Comment:
   We also should check if file name contains type or not



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org