There must be a better way.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

There must be a better way.

Daniel Persson
Hi, everyone.

I maintain a java tool that uses all the image libraries under the sun. And
they all expose the javax.imageio.spi.ImageReaderSpi service.

Because it's hard to actually merge all the service definition files I've
opted to merge them manually and add them into my META-INF/services
directory.

Then I use maven shade plugin to exclude this file from all packages and
then add it back with resources definition.

This works 25% of the time and other times I have to open the jar file and
replace this file manually. Because this is a manual step I forget to do
this in some releases so I really hope there is a better way to do this.

I've added the build definition part of the pom file to the link below.

https://pastebin.com/bGy3bvm0

Hope you have a creative solution to this problem. And thank you for a
great tool that really simplified our build process.

Best regards
Daniel
Reply | Threaded
Open this post in threaded view
|

Re: There must be a better way.

Robert Scholte-6
On Wed, 30 Aug 2017 08:52:45 +0200, Daniel Persson  
<[hidden email]> wrote:

> Hi, everyone.
>
> I maintain a java tool that uses all the image libraries under the sun.  
> And
> they all expose the javax.imageio.spi.ImageReaderSpi service.
>
> Because it's hard to actually merge all the service definition files I've
> opted to merge them manually and add them into my META-INF/services
> directory.

What's so hard?
Have you tried using  
https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ServicesResourceTransformer 
?

Robert

>
> Then I use maven shade plugin to exclude this file from all packages and
> then add it back with resources definition.
>
> This works 25% of the time and other times I have to open the jar file  
> and
> replace this file manually. Because this is a manual step I forget to do
> this in some releases so I really hope there is a better way to do this.
>
> I've added the build definition part of the pom file to the link below.
>
> https://pastebin.com/bGy3bvm0
>
> Hope you have a creative solution to this problem. And thank you for a
> great tool that really simplified our build process.
>
> Best regards
> Daniel

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

Reply | Threaded
Open this post in threaded view
|

Re: There must be a better way.

Daniel Persson
Hi Robert.

Thank you for the prompt response.

I've tried that transformer and I also tried to use this

<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">

<resource>META-INF/services/javax.imageio.spi.ImageReaderSpi</resource>
</transformer>

Sadly it doesn't work for me.

The result is always the same. The first service file is the only one that
will be present in the output.

So what I want to accomplice is that the output has a ImageReaderSpi file
that has content from all the jar files individual ImageReaderSpi in my
project.

jai-imageio-jpeg2000:
com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi

jai-imageio-core:
com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi

and so on.

Expected output:
com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi

Actual output:
com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi

Best regards

Daniel

On Wed, Aug 30, 2017 at 11:24 AM, Robert Scholte <[hidden email]>
wrote:

> On Wed, 30 Aug 2017 08:52:45 +0200, Daniel Persson <[hidden email]>
> wrote:
>
> Hi, everyone.
>>
>> I maintain a java tool that uses all the image libraries under the sun.
>> And
>> they all expose the javax.imageio.spi.ImageReaderSpi service.
>>
>> Because it's hard to actually merge all the service definition files I've
>> opted to merge them manually and add them into my META-INF/services
>> directory.
>>
>
> What's so hard?
> Have you tried using https://maven.apache.org/plugi
> ns/maven-shade-plugin/examples/resource-transformers.html#Se
> rvicesResourceTransformer ?
>
> Robert
>
>
>> Then I use maven shade plugin to exclude this file from all packages and
>> then add it back with resources definition.
>>
>> This works 25% of the time and other times I have to open the jar file and
>> replace this file manually. Because this is a manual step I forget to do
>> this in some releases so I really hope there is a better way to do this.
>>
>> I've added the build definition part of the pom file to the link below.
>>
>> https://pastebin.com/bGy3bvm0
>>
>> Hope you have a creative solution to this problem. And thank you for a
>> great tool that really simplified our build process.
>>
>> Best regards
>> Daniel
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: There must be a better way.

Robert Scholte-6
Hi Daniel,

that would be bug, both should work.
ServiceResourceTransformer would be the preferred one in this case,  
because it is classname aware, in case you want to do relocation as well.

Are you using the most recent version of the plugin?
If so, then make a small reproducable project and file an issue[1]
I would be surprised though, I consider this as basic functionality and  
would have expected more complaints if this was not working.

Robert

[1] https://issues.apache.org/jira/projects/MSHADE

On Wed, 30 Aug 2017 11:53:56 +0200, Daniel Persson  
<[hidden email]> wrote:

> Hi Robert.
>
> Thank you for the prompt response.
>
> I've tried that transformer and I also tried to use this
>
> <transformer
> implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
>
> <resource>META-INF/services/javax.imageio.spi.ImageReaderSpi</resource>
> </transformer>
>
> Sadly it doesn't work for me.
>
> The result is always the same. The first service file is the only one  
> that
> will be present in the output.
>
> So what I want to accomplice is that the output has a ImageReaderSpi file
> that has content from all the jar files individual ImageReaderSpi in my
> project.
>
> jai-imageio-jpeg2000:
> com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
>
> jai-imageio-core:
> com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
> com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
> com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
> com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
> com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
> com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
>
> and so on.
>
> Expected output:
> com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
> com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
> com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
> com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
> com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
> com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
> com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
>
> Actual output:
> com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
>
> Best regards
>
> Daniel
>
> On Wed, Aug 30, 2017 at 11:24 AM, Robert Scholte <[hidden email]>
> wrote:
>
>> On Wed, 30 Aug 2017 08:52:45 +0200, Daniel Persson  
>> <[hidden email]>
>> wrote:
>>
>> Hi, everyone.
>>>
>>> I maintain a java tool that uses all the image libraries under the sun.
>>> And
>>> they all expose the javax.imageio.spi.ImageReaderSpi service.
>>>
>>> Because it's hard to actually merge all the service definition files  
>>> I've
>>> opted to merge them manually and add them into my META-INF/services
>>> directory.
>>>
>>
>> What's so hard?
>> Have you tried using https://maven.apache.org/plugi
>> ns/maven-shade-plugin/examples/resource-transformers.html#Se
>> rvicesResourceTransformer ?
>>
>> Robert
>>
>>
>>> Then I use maven shade plugin to exclude this file from all packages  
>>> and
>>> then add it back with resources definition.
>>>
>>> This works 25% of the time and other times I have to open the jar file  
>>> and
>>> replace this file manually. Because this is a manual step I forget to  
>>> do
>>> this in some releases so I really hope there is a better way to do  
>>> this.
>>>
>>> I've added the build definition part of the pom file to the link below.
>>>
>>> https://pastebin.com/bGy3bvm0
>>>
>>> Hope you have a creative solution to this problem. And thank you for a
>>> great tool that really simplified our build process.
>>>
>>> Best regards
>>> Daniel
>>>
>>
>> ---------------------------------------------------------------------
>> 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]

Reply | Threaded
Open this post in threaded view
|

Re: There must be a better way.

Thomas Broyer-2
In reply to this post by Daniel Persson
You're using both m-assembly-p's jar-with-dependencies and m-shade-p, could
it be a conflict between them? (or possibly you don't look at the correct
JAR)
If you use m-shade-p, you don't need m-assembly-p's jar-with-dependencies;
m-shade-p does the same thing, better, and does more (class renaming,
merging service resources, etc.)

On Wed, Aug 30, 2017 at 11:54 AM Daniel Persson <[hidden email]>
wrote:

> Hi Robert.
>
> Thank you for the prompt response.
>
> I've tried that transformer and I also tried to use this
>
> <transformer
>
> implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
>
> <resource>META-INF/services/javax.imageio.spi.ImageReaderSpi</resource>
> </transformer>
>
> Sadly it doesn't work for me.
>
> The result is always the same. The first service file is the only one that
> will be present in the output.
>
> So what I want to accomplice is that the output has a ImageReaderSpi file
> that has content from all the jar files individual ImageReaderSpi in my
> project.
>
> jai-imageio-jpeg2000:
> com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
>
> jai-imageio-core:
> com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
> com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
> com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
> com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
> com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
> com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
>
> and so on.
>
> Expected output:
> com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
> com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
> com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
> com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
> com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
> com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
> com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
>
> Actual output:
> com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
>
> Best regards
>
> Daniel
>
> On Wed, Aug 30, 2017 at 11:24 AM, Robert Scholte <[hidden email]>
> wrote:
>
> > On Wed, 30 Aug 2017 08:52:45 +0200, Daniel Persson <
> [hidden email]>
> > wrote:
> >
> > Hi, everyone.
> >>
> >> I maintain a java tool that uses all the image libraries under the sun.
> >> And
> >> they all expose the javax.imageio.spi.ImageReaderSpi service.
> >>
> >> Because it's hard to actually merge all the service definition files
> I've
> >> opted to merge them manually and add them into my META-INF/services
> >> directory.
> >>
> >
> > What's so hard?
> > Have you tried using https://maven.apache.org/plugi
> > ns/maven-shade-plugin/examples/resource-transformers.html#Se
> > rvicesResourceTransformer ?
> >
> > Robert
> >
> >
> >> Then I use maven shade plugin to exclude this file from all packages and
> >> then add it back with resources definition.
> >>
> >> This works 25% of the time and other times I have to open the jar file
> and
> >> replace this file manually. Because this is a manual step I forget to do
> >> this in some releases so I really hope there is a better way to do this.
> >>
> >> I've added the build definition part of the pom file to the link below.
> >>
> >> https://pastebin.com/bGy3bvm0
> >>
> >> Hope you have a creative solution to this problem. And thank you for a
> >> great tool that really simplified our build process.
> >>
> >> Best regards
> >> Daniel
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: There must be a better way.

Daniel Persson
Hi, Robert.

I think I know what is happening here. The shaded jar replaces the original
jar the last thing that is done in the execution.
Sadly it's done only for the regular jar. Not the jar-with-dependencies one.

And yes I've updated the versions in the new build file. So assembly plugin
and shade plugin both run with 3.1.0.

Best regards

Daniel

On Wed, Aug 30, 2017 at 12:15 PM, Thomas Broyer <[hidden email]> wrote:

> You're using both m-assembly-p's jar-with-dependencies and m-shade-p, could
> it be a conflict between them? (or possibly you don't look at the correct
> JAR)
> If you use m-shade-p, you don't need m-assembly-p's jar-with-dependencies;
> m-shade-p does the same thing, better, and does more (class renaming,
> merging service resources, etc.)
>
> On Wed, Aug 30, 2017 at 11:54 AM Daniel Persson <[hidden email]>
> wrote:
>
> > Hi Robert.
> >
> > Thank you for the prompt response.
> >
> > I've tried that transformer and I also tried to use this
> >
> > <transformer
> >
> > implementation="org.apache.maven.plugins.shade.resource.
> AppendingTransformer">
> >
> > <resource>META-INF/services/javax.imageio.spi.ImageReaderSpi</resource>
> > </transformer>
> >
> > Sadly it doesn't work for me.
> >
> > The result is always the same. The first service file is the only one
> that
> > will be present in the output.
> >
> > So what I want to accomplice is that the output has a ImageReaderSpi file
> > that has content from all the jar files individual ImageReaderSpi in my
> > project.
> >
> > jai-imageio-jpeg2000:
> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
> >
> > jai-imageio-core:
> > com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
> > com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
> > com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
> > com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
> > com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
> > com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
> >
> > and so on.
> >
> > Expected output:
> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
> > com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
> > com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
> > com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
> > com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
> > com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
> > com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
> >
> > Actual output:
> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
> >
> > Best regards
> >
> > Daniel
> >
> > On Wed, Aug 30, 2017 at 11:24 AM, Robert Scholte <[hidden email]>
> > wrote:
> >
> > > On Wed, 30 Aug 2017 08:52:45 +0200, Daniel Persson <
> > [hidden email]>
> > > wrote:
> > >
> > > Hi, everyone.
> > >>
> > >> I maintain a java tool that uses all the image libraries under the
> sun.
> > >> And
> > >> they all expose the javax.imageio.spi.ImageReaderSpi service.
> > >>
> > >> Because it's hard to actually merge all the service definition files
> > I've
> > >> opted to merge them manually and add them into my META-INF/services
> > >> directory.
> > >>
> > >
> > > What's so hard?
> > > Have you tried using https://maven.apache.org/plugi
> > > ns/maven-shade-plugin/examples/resource-transformers.html#Se
> > > rvicesResourceTransformer ?
> > >
> > > Robert
> > >
> > >
> > >> Then I use maven shade plugin to exclude this file from all packages
> and
> > >> then add it back with resources definition.
> > >>
> > >> This works 25% of the time and other times I have to open the jar file
> > and
> > >> replace this file manually. Because this is a manual step I forget to
> do
> > >> this in some releases so I really hope there is a better way to do
> this.
> > >>
> > >> I've added the build definition part of the pom file to the link
> below.
> > >>
> > >> https://pastebin.com/bGy3bvm0
> > >>
> > >> Hope you have a creative solution to this problem. And thank you for a
> > >> great tool that really simplified our build process.
> > >>
> > >> Best regards
> > >> Daniel
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]
> > > For additional commands, e-mail: [hidden email]
> > >
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: There must be a better way.

Robert Scholte-6
I agree with Thomas: I can't think of a reason why you still want to use  
the maven-assembly-plugin; the result of the maven-shade-plugin should be  
all you need.

Robert

On Wed, 30 Aug 2017 13:24:18 +0200, Daniel Persson  
<[hidden email]> wrote:

> Hi, Robert.
>
> I think I know what is happening here. The shaded jar replaces the  
> original
> jar the last thing that is done in the execution.
> Sadly it's done only for the regular jar. Not the jar-with-dependencies  
> one.
>
> And yes I've updated the versions in the new build file. So assembly  
> plugin
> and shade plugin both run with 3.1.0.
>
> Best regards
>
> Daniel
>
> On Wed, Aug 30, 2017 at 12:15 PM, Thomas Broyer <[hidden email]>  
> wrote:
>
>> You're using both m-assembly-p's jar-with-dependencies and m-shade-p,  
>> could
>> it be a conflict between them? (or possibly you don't look at the  
>> correct
>> JAR)
>> If you use m-shade-p, you don't need m-assembly-p's  
>> jar-with-dependencies;
>> m-shade-p does the same thing, better, and does more (class renaming,
>> merging service resources, etc.)
>>
>> On Wed, Aug 30, 2017 at 11:54 AM Daniel Persson <[hidden email]>
>> wrote:
>>
>> > Hi Robert.
>> >
>> > Thank you for the prompt response.
>> >
>> > I've tried that transformer and I also tried to use this
>> >
>> > <transformer
>> >
>> > implementation="org.apache.maven.plugins.shade.resource.
>> AppendingTransformer">
>> >
>> >  
>> <resource>META-INF/services/javax.imageio.spi.ImageReaderSpi</resource>
>> > </transformer>
>> >
>> > Sadly it doesn't work for me.
>> >
>> > The result is always the same. The first service file is the only one
>> that
>> > will be present in the output.
>> >
>> > So what I want to accomplice is that the output has a ImageReaderSpi  
>> file
>> > that has content from all the jar files individual ImageReaderSpi in  
>> my
>> > project.
>> >
>> > jai-imageio-jpeg2000:
>> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
>> >
>> > jai-imageio-core:
>> > com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
>> >
>> > and so on.
>> >
>> > Expected output:
>> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
>> >
>> > Actual output:
>> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
>> >
>> > Best regards
>> >
>> > Daniel
>> >
>> > On Wed, Aug 30, 2017 at 11:24 AM, Robert Scholte  
>> <[hidden email]>
>> > wrote:
>> >
>> > > On Wed, 30 Aug 2017 08:52:45 +0200, Daniel Persson <
>> > [hidden email]>
>> > > wrote:
>> > >
>> > > Hi, everyone.
>> > >>
>> > >> I maintain a java tool that uses all the image libraries under the
>> sun.
>> > >> And
>> > >> they all expose the javax.imageio.spi.ImageReaderSpi service.
>> > >>
>> > >> Because it's hard to actually merge all the service definition  
>> files
>> > I've
>> > >> opted to merge them manually and add them into my META-INF/services
>> > >> directory.
>> > >>
>> > >
>> > > What's so hard?
>> > > Have you tried using https://maven.apache.org/plugi
>> > > ns/maven-shade-plugin/examples/resource-transformers.html#Se
>> > > rvicesResourceTransformer ?
>> > >
>> > > Robert
>> > >
>> > >
>> > >> Then I use maven shade plugin to exclude this file from all  
>> packages
>> and
>> > >> then add it back with resources definition.
>> > >>
>> > >> This works 25% of the time and other times I have to open the jar  
>> file
>> > and
>> > >> replace this file manually. Because this is a manual step I forget  
>> to
>> do
>> > >> this in some releases so I really hope there is a better way to do
>> this.
>> > >>
>> > >> I've added the build definition part of the pom file to the link
>> below.
>> > >>
>> > >> https://pastebin.com/bGy3bvm0
>> > >>
>> > >> Hope you have a creative solution to this problem. And thank you  
>> for a
>> > >> great tool that really simplified our build process.
>> > >>
>> > >> Best regards
>> > >> Daniel
>> > >>
>> > >
>> > >  
>> ---------------------------------------------------------------------
>> > > 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]

Reply | Threaded
Open this post in threaded view
|

Re: There must be a better way.

Daniel Persson
In reply to this post by Daniel Persson
Hi, Thomas.

You're probably right. Sadly I can't find in the documentation how to add
the main class and version information into your manifest file using the
shade plugin.

Best regards
Daniel

On Wed, Aug 30, 2017 at 1:24 PM, Daniel Persson <[hidden email]>
wrote:

> Hi, Robert.
>
> I think I know what is happening here. The shaded jar replaces the
> original jar the last thing that is done in the execution.
> Sadly it's done only for the regular jar. Not the jar-with-dependencies
> one.
>
> And yes I've updated the versions in the new build file. So assembly
> plugin and shade plugin both run with 3.1.0.
>
> Best regards
>
> Daniel
>
> On Wed, Aug 30, 2017 at 12:15 PM, Thomas Broyer <[hidden email]>
> wrote:
>
>> You're using both m-assembly-p's jar-with-dependencies and m-shade-p,
>> could
>> it be a conflict between them? (or possibly you don't look at the correct
>> JAR)
>> If you use m-shade-p, you don't need m-assembly-p's jar-with-dependencies;
>> m-shade-p does the same thing, better, and does more (class renaming,
>> merging service resources, etc.)
>>
>> On Wed, Aug 30, 2017 at 11:54 AM Daniel Persson <[hidden email]>
>> wrote:
>>
>> > Hi Robert.
>> >
>> > Thank you for the prompt response.
>> >
>> > I've tried that transformer and I also tried to use this
>> >
>> > <transformer
>> >
>> > implementation="org.apache.maven.plugins.shade.resource.Appe
>> ndingTransformer">
>> >
>> > <resource>META-INF/services/javax.imageio.spi.ImageReaderSpi</resource>
>> > </transformer>
>> >
>> > Sadly it doesn't work for me.
>> >
>> > The result is always the same. The first service file is the only one
>> that
>> > will be present in the output.
>> >
>> > So what I want to accomplice is that the output has a ImageReaderSpi
>> file
>> > that has content from all the jar files individual ImageReaderSpi in my
>> > project.
>> >
>> > jai-imageio-jpeg2000:
>> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
>> >
>> > jai-imageio-core:
>> > com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
>> >
>> > and so on.
>> >
>> > Expected output:
>> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
>> > com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
>> >
>> > Actual output:
>> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
>> >
>> > Best regards
>> >
>> > Daniel
>> >
>> > On Wed, Aug 30, 2017 at 11:24 AM, Robert Scholte <[hidden email]>
>> > wrote:
>> >
>> > > On Wed, 30 Aug 2017 08:52:45 +0200, Daniel Persson <
>> > [hidden email]>
>> > > wrote:
>> > >
>> > > Hi, everyone.
>> > >>
>> > >> I maintain a java tool that uses all the image libraries under the
>> sun.
>> > >> And
>> > >> they all expose the javax.imageio.spi.ImageReaderSpi service.
>> > >>
>> > >> Because it's hard to actually merge all the service definition files
>> > I've
>> > >> opted to merge them manually and add them into my META-INF/services
>> > >> directory.
>> > >>
>> > >
>> > > What's so hard?
>> > > Have you tried using https://maven.apache.org/plugi
>> > > ns/maven-shade-plugin/examples/resource-transformers.html#Se
>> > > rvicesResourceTransformer ?
>> > >
>> > > Robert
>> > >
>> > >
>> > >> Then I use maven shade plugin to exclude this file from all packages
>> and
>> > >> then add it back with resources definition.
>> > >>
>> > >> This works 25% of the time and other times I have to open the jar
>> file
>> > and
>> > >> replace this file manually. Because this is a manual step I forget
>> to do
>> > >> this in some releases so I really hope there is a better way to do
>> this.
>> > >>
>> > >> I've added the build definition part of the pom file to the link
>> below.
>> > >>
>> > >> https://pastebin.com/bGy3bvm0
>> > >>
>> > >> Hope you have a creative solution to this problem. And thank you for
>> a
>> > >> great tool that really simplified our build process.
>> > >>
>> > >> Best regards
>> > >> Daniel
>> > >>
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: [hidden email]
>> > > For additional commands, e-mail: [hidden email]
>> > >
>> > >
>> >
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: There must be a better way.

Thomas Broyer-2
m-shade-p takes the current project artifact as its input [1], so you can
configure it in the m-jar-p:
https://maven.apache.org/plugins/maven-jar-plugin/examples/manifest-customization.html

[1]
https://github.com/apache/maven-plugins/blob/maven-shade-plugin-3.1.0/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java#L404

On Wed, Aug 30, 2017 at 1:31 PM Daniel Persson <[hidden email]>
wrote:

> Hi, Thomas.
>
> You're probably right. Sadly I can't find in the documentation how to add
> the main class and version information into your manifest file using the
> shade plugin.
>
> Best regards
> Daniel
>
> On Wed, Aug 30, 2017 at 1:24 PM, Daniel Persson <[hidden email]>
> wrote:
>
> > Hi, Robert.
> >
> > I think I know what is happening here. The shaded jar replaces the
> > original jar the last thing that is done in the execution.
> > Sadly it's done only for the regular jar. Not the jar-with-dependencies
> > one.
> >
> > And yes I've updated the versions in the new build file. So assembly
> > plugin and shade plugin both run with 3.1.0.
> >
> > Best regards
> >
> > Daniel
> >
> > On Wed, Aug 30, 2017 at 12:15 PM, Thomas Broyer <[hidden email]>
> > wrote:
> >
> >> You're using both m-assembly-p's jar-with-dependencies and m-shade-p,
> >> could
> >> it be a conflict between them? (or possibly you don't look at the
> correct
> >> JAR)
> >> If you use m-shade-p, you don't need m-assembly-p's
> jar-with-dependencies;
> >> m-shade-p does the same thing, better, and does more (class renaming,
> >> merging service resources, etc.)
> >>
> >> On Wed, Aug 30, 2017 at 11:54 AM Daniel Persson <[hidden email]
> >
> >> wrote:
> >>
> >> > Hi Robert.
> >> >
> >> > Thank you for the prompt response.
> >> >
> >> > I've tried that transformer and I also tried to use this
> >> >
> >> > <transformer
> >> >
> >> > implementation="org.apache.maven.plugins.shade.resource.Appe
> >> ndingTransformer">
> >> >
> >> >
> <resource>META-INF/services/javax.imageio.spi.ImageReaderSpi</resource>
> >> > </transformer>
> >> >
> >> > Sadly it doesn't work for me.
> >> >
> >> > The result is always the same. The first service file is the only one
> >> that
> >> > will be present in the output.
> >> >
> >> > So what I want to accomplice is that the output has a ImageReaderSpi
> >> file
> >> > that has content from all the jar files individual ImageReaderSpi in
> my
> >> > project.
> >> >
> >> > jai-imageio-jpeg2000:
> >> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
> >> >
> >> > jai-imageio-core:
> >> > com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
> >> >
> >> > and so on.
> >> >
> >> > Expected output:
> >> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.bmp.BMPImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.pcx.PCXImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.pnm.PNMImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.raw.RawImageReaderSpi
> >> > com.github.jaiimageio.impl.plugins.tiff.TIFFImageReaderSpi
> >> >
> >> > Actual output:
> >> > com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi
> >> >
> >> > Best regards
> >> >
> >> > Daniel
> >> >
> >> > On Wed, Aug 30, 2017 at 11:24 AM, Robert Scholte <
> [hidden email]>
> >> > wrote:
> >> >
> >> > > On Wed, 30 Aug 2017 08:52:45 +0200, Daniel Persson <
> >> > [hidden email]>
> >> > > wrote:
> >> > >
> >> > > Hi, everyone.
> >> > >>
> >> > >> I maintain a java tool that uses all the image libraries under the
> >> sun.
> >> > >> And
> >> > >> they all expose the javax.imageio.spi.ImageReaderSpi service.
> >> > >>
> >> > >> Because it's hard to actually merge all the service definition
> files
> >> > I've
> >> > >> opted to merge them manually and add them into my META-INF/services
> >> > >> directory.
> >> > >>
> >> > >
> >> > > What's so hard?
> >> > > Have you tried using https://maven.apache.org/plugi
> >> > > ns/maven-shade-plugin/examples/resource-transformers.html#Se
> >> > > rvicesResourceTransformer ?
> >> > >
> >> > > Robert
> >> > >
> >> > >
> >> > >> Then I use maven shade plugin to exclude this file from all
> packages
> >> and
> >> > >> then add it back with resources definition.
> >> > >>
> >> > >> This works 25% of the time and other times I have to open the jar
> >> file
> >> > and
> >> > >> replace this file manually. Because this is a manual step I forget
> >> to do
> >> > >> this in some releases so I really hope there is a better way to do
> >> this.
> >> > >>
> >> > >> I've added the build definition part of the pom file to the link
> >> below.
> >> > >>
> >> > >> https://pastebin.com/bGy3bvm0
> >> > >>
> >> > >> Hope you have a creative solution to this problem. And thank you
> for
> >> a
> >> > >> great tool that really simplified our build process.
> >> > >>
> >> > >> Best regards
> >> > >> Daniel
> >> > >>
> >> > >
> >> > >
> ---------------------------------------------------------------------
> >> > > To unsubscribe, e-mail: [hidden email]
> >> > > For additional commands, e-mail: [hidden email]
> >> > >
> >> > >
> >> >
> >>
> >
> >
>