You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Grégory Joseph <gr...@gmail.com> on 2010/10/27 19:15:32 UTC

Including scope:provided dependencies in a shaded jar ?

Hi,

I have a project for which I'd like to create a shaded jar.
It has a bunch of dependencies in scope:provided, because they really
are, in the normal use-case of this artifact; it's meant to be
deployed as a plugin in another app, so, for example, myapp-api really
is "provided".

The project also has an assembly, which depends on these deps to be
scope:provided (so they're not included in the assembly)

If a webapp project is made and depends on this project, the
scope:provided also helps avoiding duplicated dependencies in some
cases. (I might have to double-check what I'm saying here ...)

.. but yes, this project now also needs a standalone/executable jar;
some of the "provided" dependencies are needed at runtime for this. As
far as I can tell, the shade plugin currently does not propose any
solution for this.

Is there any way this could be considered for the plugin ? Or am I
looking at it the wrong way ? Are there any alternatives ? I suppose I
could split my project and have 2 modules, one simply being the
standalone/shaded version of the other, but it seems overkill, since
they're really the same source.

I've also looked at the assembly plugin, but as far as I can tell it
doesn't have a "minify" feature yet. (and we're talking 12mb vs 500k
when minified)

I reported this as http://jira.codehaus.org/browse/MSHADE-89
yesterday, before figuring it might be better discussed here
beforehand.

Thanks for any tip or hint,

-greg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Including scope:provided dependencies in a shaded jar ?

Posted by Antonio Petrelli <an...@gmail.com>.
2010/10/27 Grégory Joseph <gr...@gmail.com>:
> .. but yes, this project now also needs a standalone/executable jar;
> some of the "provided" dependencies are needed at runtime for this. As
> far as I can tell, the shade plugin currently does not propose any
> solution for this.
>
> Is there any way this could be considered for the plugin ? Or am I
> looking at it the wrong way ? Are there any alternatives ? I suppose I
> could split my project and have 2 modules, one simply being the
> standalone/shaded version of the other, but it seems overkill, since
> they're really the same source.

The multi-module path is the best. Why do you say that they share "the
same source"? The shaded project must have a dependency on the
original project, so it takes the compiled version, not the source.

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Including scope:provided dependencies in a shaded jar ?

Posted by Grégory Joseph <gr...@gmail.com>.
Hi Jörg,

> Did you see this:
> http://maven.apache.org/plugins/maven-shade-plugin/shade-
> mojo.html#keepDependenciesWithProvidedScope

I did, but it doesn't do what I need; my understanding is that it
changes the scope of the compile-scoped deps to :provided in the
shaded jar's pom.

Antonio, Wayne,
> The multi-module path is the best. Why do you say that they share "the
> same source"? The shaded project must have a dependency on the
> original project, so it takes the compiled version, not the source.

Yeah. Not something I like to do in a minor release though.
The shaded artifact will be a pom-only project, which always seems a
little silly.
Oh well.
Thanks ;)

-g

>> I have a project for which I'd like to create a shaded jar.
>> It has a bunch of dependencies in scope:provided, because they really
>> are, in the normal use-case of this artifact; it's meant to be
>> deployed as a plugin in another app, so, for example, myapp-api really
>> is "provided".
>>
>> The project also has an assembly, which depends on these deps to be
>> scope:provided (so they're not included in the assembly)
>>
>> If a webapp project is made and depends on this project, the
>> scope:provided also helps avoiding duplicated dependencies in some
>> cases. (I might have to double-check what I'm saying here ...)
>>
>> .. but yes, this project now also needs a standalone/executable jar;
>> some of the "provided" dependencies are needed at runtime for this. As
>> far as I can tell, the shade plugin currently does not propose any
>> solution for this.
>>
>> Is there any way this could be considered for the plugin ? Or am I
>> looking at it the wrong way ? Are there any alternatives ? I suppose I
>> could split my project and have 2 modules, one simply being the
>> standalone/shaded version of the other, but it seems overkill, since
>> they're really the same source.
>>
>> I've also looked at the assembly plugin, but as far as I can tell it
>> doesn't have a "minify" feature yet. (and we're talking 12mb vs 500k
>> when minified)
>>
>> I reported this as http://jira.codehaus.org/browse/MSHADE-89
>> yesterday, before figuring it might be better discussed here
>> beforehand.
>>
>> Thanks for any tip or hint,

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Including scope:provided dependencies in a shaded jar ?

Posted by Jörg Schaible <jo...@gmx.de>.
Hi Greg,

Grégory Joseph wrote:

> Hi,
> 
> I have a project for which I'd like to create a shaded jar.
> It has a bunch of dependencies in scope:provided, because they really
> are, in the normal use-case of this artifact; it's meant to be
> deployed as a plugin in another app, so, for example, myapp-api really
> is "provided".
> 
> The project also has an assembly, which depends on these deps to be
> scope:provided (so they're not included in the assembly)
> 
> If a webapp project is made and depends on this project, the
> scope:provided also helps avoiding duplicated dependencies in some
> cases. (I might have to double-check what I'm saying here ...)
> 
> .. but yes, this project now also needs a standalone/executable jar;
> some of the "provided" dependencies are needed at runtime for this. As
> far as I can tell, the shade plugin currently does not propose any
> solution for this.
> 
> Is there any way this could be considered for the plugin ? Or am I
> looking at it the wrong way ? Are there any alternatives ? I suppose I
> could split my project and have 2 modules, one simply being the
> standalone/shaded version of the other, but it seems overkill, since
> they're really the same source.
> 
> I've also looked at the assembly plugin, but as far as I can tell it
> doesn't have a "minify" feature yet. (and we're talking 12mb vs 500k
> when minified)
> 
> I reported this as http://jira.codehaus.org/browse/MSHADE-89
> yesterday, before figuring it might be better discussed here
> beforehand.
> 
> Thanks for any tip or hint,

Did you see this:
http://maven.apache.org/plugins/maven-shade-plugin/shade-
mojo.html#keepDependenciesWithProvidedScope

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Including scope:provided dependencies in a shaded jar ?

Posted by Antonio Petrelli <an...@gmail.com>.
2010/10/29 Grégory Joseph <gr...@gmail.com>:
> The only way I can get projectB's generated shaded jar to also include
> thirdParty is to redefine that dependency in projectB and change its
> scope.

I think this point is right and was implicit in the creation of this
special module for the shaded jar.
After all, you have all the control on it.

> On of the reasons my dependencies are in scope:provided, is because we
> also build an assembly with the regular jar and a few text files.
> Dependencies don't need to be shipped with this; we use a common
> assembly descriptor where dependencies in scope:provided are excluded.

Create another module for the assembly.
This is a Maven best practice.

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Including scope:provided dependencies in a shaded jar ?

Posted by Grégory Joseph <gr...@gmail.com>.
Hi again,

>> could split my project and have 2 modules, one simply being the
>> standalone/shaded version of the other, but it seems overkill, since
>> they're really the same source.

On 27 October 2010 19:33, Wayne Fay <wa...@gmail.com> wrote:
> This is the correct approach (imo). Two artifacts, one for the
> provided artifact, another for the shaded artifact.

On 27 October 2010 19:49, Antonio Petrelli <an...@gmail.com> wrote:
> The multi-module path is the best. Why do you say that they share "the
> same source"? The shaded project must have a dependency on the
> original project, so it takes the compiled version, not the source.

This actually does not really solve my problem.

Parent:
 !-- projectA - the "regular" project, which depends on thirdParty
with scope:provided
 !-- projectB - the new "shading" project, which depends on projectA

The only way I can get projectB's generated shaded jar to also include
thirdParty is to redefine that dependency in projectB and change its
scope.

Which would be ok if projectA had that single dependency.
Unfortunately it has a few more.

On of the reasons my dependencies are in scope:provided, is because we
also build an assembly with the regular jar and a few text files.
Dependencies don't need to be shipped with this; we use a common
assembly descriptor where dependencies in scope:provided are excluded.

I just tried the same approach for this assembly, i.e extract it to a
3rd module, but I still run in the same issues.

It looks like I'll either have to add a bunch of <exclude> in my
assembly's dependency to projectA .. or re-declare all deps of
projectA in projectB. Neither is appealing nor convenient... any other
option ?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Including scope:provided dependencies in a shaded jar ?

Posted by Wayne Fay <wa...@gmail.com>.
> could split my project and have 2 modules, one simply being the
> standalone/shaded version of the other, but it seems overkill, since
> they're really the same source.

This is the correct approach (imo). Two artifacts, one for the
provided artifact, another for the shaded artifact.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org