slachiewicz opened a new issue, #876:
URL: https://github.com/apache/maven-shade-plugin/issues/876

   When a shaded jar already contains the resource an 
`IncludeResourceTransformer` writes, the build fails:
   
   ```
   [ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-shade-plugin:3.6.3-SNAPSHOT:shade (attach-shade) 
on project test: Error creating shaded jar: duplicate entry: META-INF/README.txt
   ```
   
   Reproducer: a project with `src/main/resources/META-INF/README.txt`, and
   
   ```xml
   <transformer 
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
     <resource>META-INF/README.txt</resource>
     <file>README.txt</file>
   </transformer>
   ```
   
   `IncludeResourceTransformer.canTransformResource` always returns `false` 
([IncludeResourceTransformer.java:44-46](https://github.com/apache/maven-shade-plugin/blob/master/src/main/java/org/apache/maven/plugins/shade/resource/IncludeResourceTransformer.java#L44-L46)),
 so the existing entry is copied into the jar as usual, and 
`modifyOutputStream` then writes a second entry with the same name. The common 
use, injecting a `META-INF/LICENSE` or `NOTICE`, works only when another 
transformer such as `DontIncludeResourceTransformer` drops the dependencies' 
copies first.
   
   The transformer should claim entries with its own resource name, so the 
configured file replaces them. `processResource` already records the claimed 
entry's timestamp, which suggests that was the intent.
   


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

Reply via email to