Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip specified attached artifacts from deploy #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xleon90
Copy link

@xleon90 xleon90 commented Jul 24, 2018

Suppose you have differents artifacts attached on a single Maven module. For example:

  • a shaded jar created using the "maven-shade-plugin" with "shadedArtifactAttached" attribute set to true
  • a generic jar attached using the "build-helper-maven-plugin" plugin

I've worked on my fork project in order to allow to specify artifacts to skip deploy for.
Here the usage example:

 <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-deploy-plugin</artifactId>
       <version>3.0.3-SNAPSHOT</version>
       <configuration>
         <skipAttachedArtifacts>
           <artifact>
             <groupId>${project.groupId}</groupId>
             <artifactId>${project.artifactId}</artifactId>
             <version>${project.version}</version>
             <packaging>jar</packaging>
             <classifier>shaded</classifier>
           </artifact>
           <artifact>
             <groupId>${project.groupId}</groupId>
             <artifactId>${project.artifactId}</artifactId>
             <version>${project.version}</version>
             <packaging>zip</packaging>
           </artifact>
         </skipAttachedArtifacts>
       </configuration>
</plugin>

Implementing feature I took care of:

  • write documentation
  • create two dedicated asserted junit tests on DeployMojoTest.
  • respect code styles according to constraints provided
  • test build on my use case scenario

As result you will have the following output during execution:

[INFO]
[INFO] --- maven-deploy-plugin:3.0.3-SNAPSHOT:deploy (default-deploy) @ cc-manager4j ---
[INFO] Skipping artifact [com.group.test:test-artifact:jar:shaded:1.0-SNAPSHOT]

If attached artifact to skip doesn't exists the plugin will fail the execution:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.0.3-SNAPSHOT:deploy (default-deploy) on project cc-manager4j: No attached artifact com.group.test:test-artifact:zip:shaded:1.0-SNAPSHOT to exclude from deploy found -> [Help 1]
[ERROR]

@khmarbaise
Copy link
Member

First thanks for trying to contribute...(BTW: Can you read the informations about contribution etc. here https://github.com/apache/maven-help-plugin we have not yet added the information to all plugin repositories on github)..

Maybe I misunderstand your idea...but if I have configured maven-shade-plugin to attach the artifact why should I skip deploying the artifact?
And the same question when I add an zip/artifact via build-helper-maven-plugin than the same question: Why should I don't deploy it?

Can you give an example of a real life scenario where this makes sense ?

@khmarbaise
Copy link
Member

khmarbaise commented Jul 24, 2018

So added some information https://github.com/apache/maven-deploy-plugin/tree/MDEPLOY-239 ...

@xleon90
Copy link
Author

xleon90 commented Jul 25, 2018

Thank you for sharing and introducing informations about contribution on the project. I'll follow all the indicated procedure for possible future contributions.

About needs that made me look for this solution I exposed my specific scenario as solution on the following thread on stackoverflow:
https://stackoverflow.com/questions/39286613/maven-shaded-jar-used-as-external-project-dependency/51443562#51443562

Basically I needed to attach an uber jar artifact on my maven module without versioning it on my repository. Reason is that this artifact is then included as dependency into another module and this is the one uploaded on repository ( this will allow me to exclude transitive dependencies I had instead into the skipped one ).

Moreover I found also that other people searched for this solution according to their needs.
Here for example another thread on stackoverflow:
https://stackoverflow.com/questions/17006405/exclude-jar-with-dependencies-from-deploying-to-nexus?rq=1

In general I think it could be useful for all that scenarios where user want to generate attached artifacts and just use these locally for some reason without uploading them on repository.
Furthermore I've forked from this plugin cause it already provides the "skip" option that allows to bypass deploy for primary artifact and all attached ones also. I thought so that this solution can help also users that want to bypass only a custom set of attached artifacts.

@rvesse
Copy link
Member

rvesse commented Nov 26, 2020

Another practical use case, due to the constraints of our CI/CD system some of our projects use Apache Maven as the overarching build tool but use plugins to invoke other tools - docker, helm, rpmbuild - to package non-Maven things based upon our Maven build outputs. For example we have modules with packaging type war that will also package the built war into a Docker image with Jetty when an optional profile (-Pdocker) is activated.

Then for ease of integration testing within our large multi-modules builds we have these plugins attach Maven artifacts as well, this lets us then have other modules depend on those artifacts explicitly to enforce required module build order and that the developer activated the right profile. BUT we don't actually want to deploy these attached artifacts because the original artifacts e.g. the Docker images themselves are going to get deployed by non-Maven post-processing steps to their own appropriate repositories provided as part of our CI/CD system.

TL;DR

We use Maven to build non-Maven artifacts (e.g. Docker images) that don't want/need to be deployed to our Maven repository

@reza-namazi
Copy link

another usecase is i have a shaded artifact which i don't want to deploy to remote repository even i skip the main project artifact to deploy the rpm artifact but still the shaded artifact is deployed there! there must be a way to skip base in classifier.
the reason for this is really simple and necessary.

@micheljung
Copy link

In my case, I produce an -executable JAR with the spring-boot-maven-plugin which is a JAR prefixed with a shell script or so. Our artifact repository, however, doesn't allow uploading such invalid JARs (and the artifact of interest is the resulting RPM anyways). Therefore, I'd like to exclude it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants