You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "cstamas (via GitHub)" <gi...@apache.org> on 2023/02/22 13:01:18 UTC

[GitHub] [maven-shade-plugin] cstamas commented on a diff in pull request #175: [MSHADE-438] Update to Maven 3.2.5

cstamas commented on code in PR #175:
URL: https://github.com/apache/maven-shade-plugin/pull/175#discussion_r1114290727


##########
src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java:
##########
@@ -846,29 +833,29 @@ private void replaceFile( File oldFile, File newFile )
     private void copyFiles( File source, File target )
         throws IOException
     {
-        try ( InputStream in = new FileInputStream( source );
-              OutputStream out = new FileOutputStream( target ) )
+        try ( InputStream in = Files.newInputStream( source.toPath() );
+              OutputStream out = Files.newOutputStream( target.toPath() ) )
         {
             IOUtil.copy( in, out );
         }
     }
 
     private File resolveArtifactForClassifier( Artifact artifact, String classifier )
     {
-        DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
-        coordinate.setGroupId( artifact.getGroupId() );
-        coordinate.setArtifactId( artifact.getArtifactId() );
-        coordinate.setVersion( artifact.getVersion() );
-        coordinate.setExtension( "jar" );
-        coordinate.setClassifier( classifier );
+        ArtifactType artifactType = session.getRepositorySession().getArtifactTypeRegistry().get( artifact.getType() );

Review Comment:
   This is NPE prone: i forgot that resolver ArtifactTypeRegistry is DIFFERENT that maven's ArtifactHandlerManager (never returns null).



-- 
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