[ 
https://issues.apache.org/jira/browse/MDEPLOY-311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17760634#comment-17760634
 ] 

ASF GitHub Bot commented on MDEPLOY-311:
----------------------------------------

slawekjaranowski commented on code in PR #42:
URL: 
https://github.com/apache/maven-deploy-plugin/pull/42#discussion_r1310863949


##########
src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java:
##########
@@ -274,9 +274,7 @@ public void execute() throws MojoExecutionException, 
MojoFailureException {
                 classifier = artifactType.getClassifier();
             }
         }
-        Artifact mainArtifact = new DefaultArtifact(
-                        groupId, artifactId, classifier, isFilePom ? "pom" : 
getExtension(file), version)
-                .setFile(file);
+        Artifact mainArtifact = new DefaultArtifact(groupId, artifactId, 
classifier, packaging, version).setFile(file);

Review Comment:
   Please look at java doc: 
https://maven.apache.org/resolver/apidocs/org/eclipse/aether/artifact/DefaultArtifact.html#%3Cinit%3E(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
   
   fourth parameter is a file extension not packaging



##########
src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java:
##########
@@ -276,6 +276,45 @@ public void testDeployIfArtifactIsNotJar() throws 
Exception {
         assertTrue(file.exists());
     }
 
+    public void testDeployFileIfPackagingIsSet() throws Exception {
+        File testPom = new File(getBasedir(), 
"target/test-classes/unit/deploy-file-packaging/plugin-config.xml");

Review Comment:
   This file is missing in PR



##########
src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java:
##########
@@ -274,9 +274,7 @@ public void execute() throws MojoExecutionException, 
MojoFailureException {
                 classifier = artifactType.getClassifier();
             }
         }
-        Artifact mainArtifact = new DefaultArtifact(
-                        groupId, artifactId, classifier, isFilePom ? "pom" : 
getExtension(file), version)
-                .setFile(file);
+        Artifact mainArtifact = new DefaultArtifact(groupId, artifactId, 
classifier, packaging, version).setFile(file);

Review Comment:
   instead of `getExtension(file)` we can use `artifactType.getExtension()` as 
improvements





> Regression in 3.0.0: deploy-file: -Dpackaging is not considered during 
> artifact upload
> --------------------------------------------------------------------------------------
>
>                 Key: MDEPLOY-311
>                 URL: https://issues.apache.org/jira/browse/MDEPLOY-311
>             Project: Maven Deploy Plugin
>          Issue Type: Bug
>          Components: deploy:deploy-file
>    Affects Versions: 3.0.0, 3.1.0, 3.1.1
>            Reporter: Sebastian Ratz
>            Priority: Major
>
> Regression in [https://github.com/apache/maven-deploy-plugin/pull/26]
>  
> Property passed via {{-Dpackaging}} is not considered anymore during upload. 
> Instead, packaging is always derived from the file name.
>  
> To reproduce:
>  
> {{$ mvn -Dfile=foo.zip -DgroupId=com.bar -Dclassifier=baz 
> -DrepositoryId=deploy.snapshots -DartifactId=foo 
> -D{*}packaging=alterantivepackaging{*} -Dversion=1.0.0-SNAPSHOT 
> deploy:{*}3.0.0-M2{*}:deploy-file -Durl=file:./repo}}
> {{...}}
> {{Uploading to deploy.snapshots: 
> file:./repo/com/bar/foo/1.0.0-SNAPSHOT/foo-1.0.0-20230703.093021-2-baz{*}.alterantivepackaging{*}}}
> {{...}}
>  
> {{$ mvn -Dfile=foo.zip -DgroupId=com.bar -Dclassifier=baz 
> -DrepositoryId=deploy.snapshots -DartifactId=foo 
> -Dpackaging=alterantivepackaging -Dversion=1.0.0-SNAPSHOT 
> deploy:{*}3.0.0{*}:deploy-file -Durl=file:./repo}}
> {{...}}
> {{Uploading to deploy.snapshots: 
> file:./repo/com/bar/foo/1.0.0-SNAPSHOT/foo-1.0.0-20230703.093125-3-baz.zip}}
> {{...}}
>  
> The problematic line is
> [https://github.com/apache/maven-deploy-plugin/blob/707ab61615606053eb816e7c96d1fc276a80a47f/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java#L278C58-L278C96]
> Here,
> {{packaging}}
> should be used instead of
> {{isFilePom ? "pom" : getExtension(file)}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to