Re: Maven shade plugin: Duplicate entry in META-INF/service

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Maven shade plugin: Duplicate entry in META-INF/service

Matt Foley
Hi Jan,
See also https://github.com/apache/maven-shade-plugin/pull/14 and MSHADE-259

I stalled on it because it appears to be a lot of work to create unit tests for maven plugins — and there weren’t examples to follow in the shade plugin.
That said, I’m not sure what I did is the right way to fix it.  I’ve seen emails go by that indicate the possibility of duplication in attachment lists affects several plugins, and the best way would be a global change in the underlying methods for “attachArtifact” that checks to see if the requested item is already there and not duplicate it if so (without error).

Regards,
—Matt

On Nov 28, 2019, at 7:03 AM, Jan Lukavský <[hidden email]> wrote:

Hi Maven :),

I encountered an exception in my build and I'm not sure if there is something wrong with how I structure tasks in my pom.xml, or there is a room for improvement of the shade plugin.

The symptoms are as follows:

 - mvn install works just fine

 - mvn deploy fails on 'duplicate error: META-INF/service/....' while shading test jar

The reason for that seems that it includes the regular (not test-jar), and that one already includes the shaded service. When shading with the other dependencies, this fails. I managed to fix this locally with [1], but I'm not sure if this is a proper fix. I didn't fill any JIRA yet, because I wanted to check with you what the best solution should look like. I also don't know when or how this broke, but at least somewhat in early 2019 this worked. I probably changed the shade plugin to latest version later this year.

Thanks for comments and suggestions!

Jan

[1] https://github.com/apache/maven-shade-plugin/pull/32


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Maven shade plugin: Duplicate entry in META-INF/service

Jan Lukavský
Hi Chris,

my pom.xml looks like this [1]. The transformer you suggest is in place.

I think that it would help to not shade the test jar, but I'm using
shaded guava, which is bundled into core dependencies, so that might be
a little complicated. Possible, though.

This might be (maybe remotely) related to that the test-jar should
depend on the core jar through dependency-reduced-pom.xml? Might be
related to [2]?

Jan

[1]
https://github.com/O2-Czech-Republic/proxima-platform/blob/master/beam/io-pubsub/pom.xml#L41

[2] https://issues.apache.org/jira/browse/MSHADE-206

On 12/3/19 10:56 AM, Christofer Dutz wrote:

> Hi Jan,
>
> are you using any of the shade transformers? We had similar problems in the PLC4X project, but configuring:
>
>              <transformers>
>                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
>              </transformers>
>
> Helped quite a bit.
>
> Have a look here:
> https://github.com/apache/plc4x/blob/develop/pom.xml#L1286
>
> Hope this helps.
>
> Chris
>
> Am 03.12.19, 10:43 schrieb "Jan Lukavský" <[hidden email]>:
>
>      Hi Matt,
>      
>      thanks for reaction. Is there a workaround around this? I think that the
>      PR I propose is "safe" and might be considered as a hotfix before a
>      proper solution is found? I don't know how is the release cycle of maven
>      plugins defined, but if there is an upcoming release soon, this might help?
>      
>      Jan
>      
>      On 12/2/19 8:06 PM, Matt Foley wrote:
>      > Hi Jan,
>      > See also https://github.com/apache/maven-shade-plugin/pull/14 and MSHADE-259
>      >
>      > I stalled on it because it appears to be a lot of work to create unit tests for maven plugins — and there weren’t examples to follow in the shade plugin.
>      > That said, I’m not sure what I did is the right way to fix it.  I’ve seen emails go by that indicate the possibility of duplication in attachment lists affects several plugins, and the best way would be a global change in the underlying methods for “attachArtifact” that checks to see if the requested item is already there and not duplicate it if so (without error).
>      >
>      > Regards,
>      > —Matt
>      >
>      > On Nov 28, 2019, at 7:03 AM, Jan Lukavský <[hidden email]> wrote:
>      >
>      > Hi Maven :),
>      >
>      > I encountered an exception in my build and I'm not sure if there is something wrong with how I structure tasks in my pom.xml, or there is a room for improvement of the shade plugin.
>      >
>      > The symptoms are as follows:
>      >
>      >   - mvn install works just fine
>      >
>      >   - mvn deploy fails on 'duplicate error: META-INF/service/....' while shading test jar
>      >
>      > The reason for that seems that it includes the regular (not test-jar), and that one already includes the shaded service. When shading with the other dependencies, this fails. I managed to fix this locally with [1], but I'm not sure if this is a proper fix. I didn't fill any JIRA yet, because I wanted to check with you what the best solution should look like. I also don't know when or how this broke, but at least somewhat in early 2019 this worked. I probably changed the shade plugin to latest version later this year.
>      >
>      > Thanks for comments and suggestions!
>      >
>      > Jan
>      >
>      > [1] https://github.com/apache/maven-shade-plugin/pull/32
>      >
>      >
>      > ---------------------------------------------------------------------
>      > To unsubscribe, e-mail: [hidden email]
>      > For additional commands, e-mail: [hidden email]
>      >
>      >
>      >
>      
>      ---------------------------------------------------------------------
>      To unsubscribe, e-mail: [hidden email]
>      For additional commands, e-mail: [hidden email]
>      
>      
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]