You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Dagan Sandler <da...@gmail.com> on 2018/05/13 10:52:01 UTC

Deploy shaded jar with an without classifier simultaneously

Hi all,

I'll start by saying that I'm aware this is not an ideal configuration and
I only need this as an intermediate solution to a larger problem I'm
dealing with which is out of the scope of this question.

I'm wondering if there's an easy way to do this with maven-shade-plugin
only.

My current situation is that I have an artifact being packaged as a shaded
jar with all its dependencies, let's call it *my-shaded-module. *This
artifact is currently being deployed with a single artifact (the shaded
jar) - named my-shaded-module, without any qualifier*.*

My end goal is to have this module deployed with 2 artifacts - a simple
(plain) jar with no classifier, and the shaded jar with a "shaded"
classifier. I know how to do this, but some outside concerns are limiting
my ability to do this immediately.

What I'd like to achieve for the intermediate solution is to deploy this
artifact in its shaded form twice for every build, meaning that running mvn
deploy will result in 2 artifacts being deployed:
1. my-shaded-module.jar
2. my-shaded-module-shaded.jar
Both of which are supposed to be shaded at this point.

I can probably do it using some additional plugins like assembly plugin or
something but I'm hoping maybe someone has a solution for a simple idea of
how to do this, maybe with maven-shade-plugin alone.
Keep in mind that this is a temporary solution, hence why I'm trying to
avoid introducing additional plugins to the build.

Hope this was clear enough

Thanks,
Dagan.

Re: Deploy shaded jar with an without classifier simultaneously

Posted by Dagan Sandler <da...@gmail.com>.
Thanks!
I think the deploy:deploy-file is meant mostly for command line usage and I
need this deployment as part of my build (need same SNAPSHOT version), so I
don't think it will answer my needs.

I ended up using build-helper-maven plugin with the following configuration
(assume that the maven-shade-plugin is building the shaded jar as the main
artifact)

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
                <goal>attach-artifact</goal>
            </goals>
            <configuration>
                <artifacts>
                    <artifact>

<file>${project.build.directory}/${project.build.finalName}.jar</file> <!--
the main artifact of the project -->
                        <type>jar</type>
                        <classifier>shaded</classifier>
                    </artifact>
                </artifacts>
            </configuration>
        </execution>
    </executions>
</plugin>

I think this is the simplest solution to the problem.



On Sun, May 13, 2018 at 2:04 PM, Golan, Yaron <yg...@intl.att.com> wrote:

> Not sure if my proposal will fit your needs, but I'd try to run the
> deploy:deploy-file goal right after the default deploy phase.
>
> The default deploy will upload your default jar while the second execution
> will upload the shaded one.
> Or the other way (order) around.
>
> Bottom line is that you'll have both jars uploaded to the artifacts
> repository.
>
>
>
> YG
>
>
>
>
>
> -----Original Message-----
> From: Dagan Sandler [mailto:dagansandler@gmail.com]
> Sent: Sunday, May 13, 2018 13:52
> To: Maven Users List <us...@maven.apache.org>
> Subject: Deploy shaded jar with an without classifier simultaneously
>
> Hi all,
>
> I'll start by saying that I'm aware this is not an ideal configuration and
> I only need this as an intermediate solution to a larger problem I'm
> dealing with which is out of the scope of this question.
>
> I'm wondering if there's an easy way to do this with maven-shade-plugin
> only.
>
> My current situation is that I have an artifact being packaged as a shaded
> jar with all its dependencies, let's call it *my-shaded-module. *This
> artifact is currently being deployed with a single artifact (the shaded
> jar) - named my-shaded-module, without any qualifier*.*
>
> My end goal is to have this module deployed with 2 artifacts - a simple
> (plain) jar with no classifier, and the shaded jar with a "shaded"
> classifier. I know how to do this, but some outside concerns are limiting
> my ability to do this immediately.
>
> What I'd like to achieve for the intermediate solution is to deploy this
> artifact in its shaded form twice for every build, meaning that running mvn
> deploy will result in 2 artifacts being deployed:
> 1. my-shaded-module.jar
> 2. my-shaded-module-shaded.jar
> Both of which are supposed to be shaded at this point.
>
> I can probably do it using some additional plugins like assembly plugin or
> something but I'm hoping maybe someone has a solution for a simple idea of
> how to do this, maybe with maven-shade-plugin alone.
> Keep in mind that this is a temporary solution, hence why I'm trying to
> avoid introducing additional plugins to the build.
>
> Hope this was clear enough
>
> Thanks,
> Dagan.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

RE: Deploy shaded jar with an without classifier simultaneously

Posted by "Golan, Yaron" <yg...@intl.att.com>.
Not sure if my proposal will fit your needs, but I'd try to run the deploy:deploy-file goal right after the default deploy phase.

The default deploy will upload your default jar while the second execution will upload the shaded one.
Or the other way (order) around.

Bottom line is that you'll have both jars uploaded to the artifacts repository.



YG





-----Original Message-----
From: Dagan Sandler [mailto:dagansandler@gmail.com] 
Sent: Sunday, May 13, 2018 13:52
To: Maven Users List <us...@maven.apache.org>
Subject: Deploy shaded jar with an without classifier simultaneously

Hi all,

I'll start by saying that I'm aware this is not an ideal configuration and I only need this as an intermediate solution to a larger problem I'm dealing with which is out of the scope of this question.

I'm wondering if there's an easy way to do this with maven-shade-plugin only.

My current situation is that I have an artifact being packaged as a shaded jar with all its dependencies, let's call it *my-shaded-module. *This artifact is currently being deployed with a single artifact (the shaded
jar) - named my-shaded-module, without any qualifier*.*

My end goal is to have this module deployed with 2 artifacts - a simple
(plain) jar with no classifier, and the shaded jar with a "shaded"
classifier. I know how to do this, but some outside concerns are limiting my ability to do this immediately.

What I'd like to achieve for the intermediate solution is to deploy this artifact in its shaded form twice for every build, meaning that running mvn deploy will result in 2 artifacts being deployed:
1. my-shaded-module.jar
2. my-shaded-module-shaded.jar
Both of which are supposed to be shaded at this point.

I can probably do it using some additional plugins like assembly plugin or something but I'm hoping maybe someone has a solution for a simple idea of how to do this, maybe with maven-shade-plugin alone.
Keep in mind that this is a temporary solution, hence why I'm trying to avoid introducing additional plugins to the build.

Hope this was clear enough

Thanks,
Dagan.

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