deploy to repository prebuild artifacts Maven - maven

I have run mvn install on my project then at the end I wanted to run mvn deploy -P profile1 to deploy selective modules from the project.
The issue is that mvn deploy performs build all over again when I just want to deploy the artifacts that were already compiled.
How do I do that?

Related

What is the difference between deploying an artifact into Artifactory with 'mvn deploy' command and with Artifactory UI?

I usually use mvn versions:use-latest-versions command to update my dependencies to the latest ones which other teams have been deployed to our free Jfrog's Artifactory server on our local address : http://192.168.100.243:8082/artifactory/X_Douran/.
My problem is when I deploy an artifact (a jar file) with Artifactory UI or with curl (using Jfrog's Rest Api), the command mvn versions:use-latest-versions doesn't work correctly and do not update my pom but when I run mvn clean deploy on my source code of my dependent project then running mvn versions:use-latest-versions on my final project it works correctly and do update my dependency in my pom.
So I want to know what is the different between deploying via Artifactory UI and deploying via mvn clean deploy ?
You always need to deploy the POM along the JAR, otherwise Maven will not work correctly with these dependencies. Furthermore, you need to make sure that the metadata files are updated. I am not sure that Artifactory does this if you deploy using curl or the UI.
Deploying your own JARs regularly through the UI is not recommended. You should build them on a build server (like Jenkins) and then automatically deploy them to Artifactory.
Changing JAR files "by hand" should be forbidden.

locally installed jar dependency in github action

In my maven project, I'm creating a jar locally and specifying it in pom as a dependency. In GitHub action install step is working mvn install:install-file and it is installing jar at location /root/.m2/repository/.
But in the next command to run tests mvn clean test it's checking that dependency in maven central and failing. How do we use dependency locally installed in case of GitHub action?

What maven goal is required to run maven sonar analysis?

I have seen sonar builds failing if I run mvn package or mvn verify as build goals, however if I change it to mvn install it passes.
Can you explain why maven install goal is needed for sonar to work properly?
In a multi-module build an aggregator plugin can't resolve dependencies from target folder. So you have two options:
mvn clean install && mvn sonar:sonar as two separate processes
mvn clean package sonar:sonar as a single reactor

Getting Artifactory Plugin to work with Jenkins and Maven

I have a large Maven project in Jenkins. It consists of a parent project, and about a dozen local projects. Using Jenkins, I am able to do mvndeploy` and for the build to successfully deploy to my Artifactory repository.
However, I can't seem to get the Jenkin's Artifactory plugin to work itself to work.
My Artifactory setting in Jenkins:
And here's the setting for our job:
When using the Jenkins Artifactory Plugin you should execute mvn install instead of mvn deploy.
This is because the plugin collects the published artifacts from Maven and when executing mvn deploy directly you are kind of by-passing it's behavior.
Use Build Step "Invoke Artifactory Maven 3" when working with Artifactory plugin. And most preferably use goals "clean install"
I had the same problem and resolved by adding details under Build Environment -> Generic-Artifactory Integration as shown in below image
Published Artifacts now started uploading into desired location in artifactory.

Running both default and production profile during release

My build is as follows:
The first is the normal build (mvn clean install)
The other is a profile activated by property (mvn clean install -Dbuild=prod)
The first deploys to Nexus.
The second profile deploys to a production server.
How can I run both builds during the Maven release cycle.
I would separate the nexus-deploy out to a different profile and use multiple target execution:
Create a different profile to cater for the normal build and execute both targets on the build server like so:
mvn clean install -Dbuild=prod -Pdeploy
mabe Cargo can to do this. look Appfuse for example, it use mvn jetty:run-war to deploy in jetty and mvn cargo:start start to deploy to tomcat

Resources