Pages

Saturday 4 December 2021

Maven

 Basic commands

mvn compile     # compile the project
mvn deploy     # validate--> compile--> test--> package -->verify --> install -->deploy

mvn clean package  -Dmaven.test.skip=true # clean the build files and do package but skip test file compilation


Run integration test

mvn failsafe:integration-test

Skip Nexus deploy plugin

You can use the Nexus Staging Plugin's property skipNexusStagingDeployMojo to achieve this:

mvn clean package deploy:deploy -DskipNexusStagingDeployMojo=true 
-DaltDeploymentRepository=snapshots::default::https://my.nexus.host/content/repositories/snapshots-local

It is important to explicitly invoke package and then deploy:deploy, as otherwise (when only invoking mvn deploy) the default execution of the maven-deploy-plugin is suppressed by the Nexus Staging Plugin (even with the skip set to true).


fail at end


-fae,--fail-at-end Only fail the build afterwards; allow all non-impacted builds to continue
-fn,--fail-never NEVER fail the build, regardless of project result


Create src archive explicitly

org.apache.maven.plugins:maven-source-plugin:3.2.0:jar




Maven deploy locally

mvn deploy -DaltDeploymentRepository=local::file:./target/staging-deploy