You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Fischer, Wolfram" <wo...@sap.com.INVALID> on 2021/09/06 11:03:09 UTC

Re: Apache Maven Shade Plugin command line usage

Hi Romain,

thank you very much for your reply!

I did not understand fully, what you wrote, so please allow me to clarify with some questions:

>     We can set property values foe most params.

Yes, although the "finalName" and "minimizeJar" parameters are not supported on the command line, which are the two important ones for our use-case. I would like to understand, if there never was any demand for setting this parameters on the command line, or, if there are technical reasons for not providing them.

>    Side note: an option you can use is an extension which would auto configure
>    shade plugin. Customizes mvn instance (ext/ or using a custom launcher/cp)
>   over the project descriptors.

I found this information on extensions: https://maven.apache.org/guides/mini/guide-using-extensions.html

Please let me phrase it in my own words to check if I understand your suggestion/guessing right what you imply:
- We build an extension, which enhances the 'in-memory' POM with our parameters and the Maven Shade plugin
- We would hook the extension into a lifecycle phase like pre-validate or pre-package (?)
- How could we call/incorporate the extension from the command line? The example says to add the extension to the POM file and gives no example how to use it from the command line (https://maven.apache.org/examples/maven-3-lifecycle-extensions.html) 

Further, our team is still puzzled, why the Maven Shade plugin has a message, that CLI usage is not supported and it seems there is no interest for exposing more parameters via the command line.  Do you happen to know why this is an issue or perhaps could point me to some resources, which might help me to learn about the technical or cultural reasons for this?

Kind regards,
Wolfram


On 31.08.21, 21:37, "Romain Manni-Bucau" <rm...@gmail.com> wrote:

    Hi

    We can set property values foe most params.

    Side note: an option you can use is an extension which would auto configure
    shade plugin. Customizes mvn instance (ext/ or using a custom launcher/cp)
    over the project descriptors.


    Le mar. 31 août 2021 à 19:05, Fischer, Wolfram
    <wo...@sap.com.invalid> a écrit :

    > Hi all,
    >
    > we (research team) use the Apache Maven Shade Plugin to identify bloated
    > code.
    >
    > We execute the shade plugin with the minimizeJar option and compare the
    > classes which end up in the generated fat jar with the complete set of
    > classes from the project and its direct and transitive dependencies.
    >
    > To automate this, we had to expose the finalName and minimizeJar
    > parameters as properties to set them from the command line.
    >
    > Modifying the pom.xml files is not an option for us, because we run the
    > shade plugin against hundreds of projects.
    >
    > Why is it not supported to execute the shade plugin from the command line
    > [0]?
    >
    > When we compared the output of the shade plugin configured via the pom.xml
    > file and using our modified shade plugin from the command line, we got
    > exactly the same results.
    >
    > I would happily create a PR and expose a subset or all parameters via the
    > property attribute in the Parameter annotations.
    >
    > Kind regards,
    > Wolfram
    >
    > [0]
    > https://github.com/copyonwrite/maven-shade-plugin/blob/c648ccfade767acd5a59893a1719b58ed02fad99/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java#L644
    >


Re: Apache Maven Shade Plugin command line usage

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le lun. 6 sept. 2021 à 13:03, Fischer, Wolfram
<wo...@sap.com.invalid> a écrit :

> Hi Romain,
>
> thank you very much for your reply!
>
> I did not understand fully, what you wrote, so please allow me to clarify
> with some questions:
>
> >     We can set property values foe most params.
>
> Yes, although the "finalName" and "minimizeJar" parameters are not
> supported on the command line, which are the two important ones for our
> use-case. I would like to understand, if there never was any demand for
> setting this parameters on the command line, or, if there are technical
> reasons for not providing them.
>

No technical reasons so we can set property="shade.xxxx" on all parameters
and/or add overrides for defaults ones (like finalName).
One thing is that you can always use <properties> and wire them in shade
configuration and reach your goal if the plugin is defined in the pom.


>
> >    Side note: an option you can use is an extension which would auto
> configure
> >    shade plugin. Customizes mvn instance (ext/ or using a custom
> launcher/cp)
> >   over the project descriptors.
>
> I found this information on extensions:
> https://maven.apache.org/guides/mini/guide-using-extensions.html
>
> Please let me phrase it in my own words to check if I understand your
> suggestion/guessing right what you imply:
> - We build an extension, which enhances the 'in-memory' POM with our
> parameters and the Maven Shade plugin
> - We would hook the extension into a lifecycle phase like pre-validate or
> pre-package (?)
> - How could we call/incorporate the extension from the command line? The
> example says to add the extension to the POM file and gives no example how
> to use it from the command line (
> https://maven.apache.org/examples/maven-3-lifecycle-extensions.html)


The extension enables to inject any form of plugin, including shade plugin
from the raw pom.
So technically you can use any maven project properties to read the conf
you want/override and or any system property to inject the right shade
plugin configuration.
In other words, based on -D you can make maven see the full shade
<plugin>....<configuration></></> blocks as if it would be in the pom
directly.


>
>
> Further, our team is still puzzled, why the Maven Shade plugin has a
> message, that CLI usage is not supported and it seems there is no interest
> for exposing more parameters via the command line.  Do you happen to know
> why this is an issue or perhaps could point me to some resources, which
> might help me to learn about the technical or cultural reasons for this?
>

shade only makes sense when there is an artifact so NOT common CLI case
(think archetype usage which is what CLI often means - even if wrong
strictly speaking. Other usage are CLI friendly otherwise.


>
> Kind regards,
> Wolfram
>
>
> On 31.08.21, 21:37, "Romain Manni-Bucau" <rm...@gmail.com> wrote:
>
>     Hi
>
>     We can set property values foe most params.
>
>     Side note: an option you can use is an extension which would auto
> configure
>     shade plugin. Customizes mvn instance (ext/ or using a custom
> launcher/cp)
>     over the project descriptors.
>
>
>     Le mar. 31 août 2021 à 19:05, Fischer, Wolfram
>     <wo...@sap.com.invalid> a écrit :
>
>     > Hi all,
>     >
>     > we (research team) use the Apache Maven Shade Plugin to identify
> bloated
>     > code.
>     >
>     > We execute the shade plugin with the minimizeJar option and compare
> the
>     > classes which end up in the generated fat jar with the complete set
> of
>     > classes from the project and its direct and transitive dependencies.
>     >
>     > To automate this, we had to expose the finalName and minimizeJar
>     > parameters as properties to set them from the command line.
>     >
>     > Modifying the pom.xml files is not an option for us, because we run
> the
>     > shade plugin against hundreds of projects.
>     >
>     > Why is it not supported to execute the shade plugin from the command
> line
>     > [0]?
>     >
>     > When we compared the output of the shade plugin configured via the
> pom.xml
>     > file and using our modified shade plugin from the command line, we
> got
>     > exactly the same results.
>     >
>     > I would happily create a PR and expose a subset or all parameters
> via the
>     > property attribute in the Parameter annotations.
>     >
>     > Kind regards,
>     > Wolfram
>     >
>     > [0]
>     >
> https://github.com/copyonwrite/maven-shade-plugin/blob/c648ccfade767acd5a59893a1719b58ed02fad99/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java#L644
>     >
>
>