Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
EE4J Maven Publishing
To publish Maven artifacts and release them, you need to use the nexus-staging-maven-plugin. The plugin has been configured in the ee4j parent pom, starting with version 1.0.5. Make sure you're using at least that version:
<parent> <groupId>org.eclipse.ee4j</groupId> <artifactId>project</artifactId> <version>1.0.5</version> </parent>
The configuration in the parent pom causes the Maven deploy operation to be done using the nexus-staging-maven-plugin instead.
I created a job to do the build and deploy to staging for JAF. The same approach should work for most simple projects.
Create a freestyle job using the usual setup with all the required configuration and security injection. Here's the script I use for the job. It can be used to build and deploy either a SNAPSHOT release or a final release. Note that it depends on the version number already having been updated if you want to deploy a final release. You could replace the simple use of "mvn deploy" with the use of the maven-release-plugin, as others have explained. The key parts of this script are the use of the nexus-staging-maven-plugin to clean up any existing staging repositories to allow this job to be run multiple times to redeploy the artifacts.
Note that I have deploy-snapshot and deploy-release profiles in my pom, largely for historical reasons. Change or remove those as appropriate. You will need to customize the Maven build and deploy commands for your project.
TOOLS_PREFIX='/opt/tools' JAVA_PREFIX="${TOOLS_PREFIX}/java/oracle" MVN_HOME="${TOOLS_PREFIX}/apache-maven/latest" JAVA_HOME="${JAVA_PREFIX}/jdk-8/latest" PATH="${MVN_HOME}/bin:${JAVA_HOME}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" HELP_PLUGIN='org.apache.maven.plugins:maven-help-plugin:2.1.1' # Workaround: GPG initialization gpg --batch --import ${KEYRING} for fpr in $(gpg --list-keys --with-colons | awk -F: '/fpr:/ {print $10}' | sort -u); do echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust; done mvnq() { # filter out progress reports (-B) and download details mvn -B "$@" | grep -v '^\[INFO\] Download' } # # If we're deploying a SNAPSHOT release, it's easy. # VERSION=$(mvn -B ${HELP_PLUGIN}:evaluate \ -Dexpression=project.version 2> /dev/null | grep -v INFO) case "$VERSION" in *-SNAPSHOT) mvnq -Pstaging -Pdeploy-snapshot clean deploy exit ;; esac # # Clean up from any previous failures # List all the profiles, then for each profile, # list all the repositories and drop them. # for name in $(mvnq nexus-staging:rc-list-profiles | \ grep -v 'Central Bundles' | \ awk '$3 == "BOTH" {print $4}') do name=${name//./} # squash out all the dots for id in $(mvnq nexus-staging:rc-list | \ awk '$1 ~ /\[INFO\]/ && $2 ~ /^'"${name}"'\-[0-9]+$/ {print $2}') do echo "Dropping $id" mvnq -DstagingRepositoryId="$id" nexus-staging:rc-drop done done # # Build and deploy # # Since we depend on other staged artifacts, need to use -Pstaging # when building and deploying. # mvnq -Poss-release -Pstaging -Pdeploy-release clean deploy
When the above job is used to deploy a final release to a staging repository, the deployed artifacts can be tested, and a Release Review can be started. Once the testing is complete and the Release Review is approved, a job with the following script is used to actually release the staged artifacts. This script should not need to be customized per project.
TOOLS_PREFIX='/opt/tools' JAVA_PREFIX="${TOOLS_PREFIX}/java/oracle" MVN_HOME="${TOOLS_PREFIX}/apache-maven/latest" JAVA_HOME="${JAVA_PREFIX}/jdk-8/latest" PATH="${MVN_HOME}/bin:${JAVA_HOME}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" mvnq() { # filter out progress reports (-B) and download details mvn -B "$@" | grep -v '^\[INFO\] Download' } # # List all the profiles, then for each profile, # list all the repositories and release them. # XXX - Assumes we want to release everything that's currently staged. # for name in $(mvnq nexus-staging:rc-list-profiles | \ grep -v 'Central Bundles' | \ awk '$3 == "BOTH" {print $4}') do name=${name//./} # squash out all the dots for id in $(mvnq nexus-staging:rc-list | \ awk '$1 ~ /\[INFO\]/ && $2 ~ /^'"${name}"'\-[0-9]+$/ {print $2}') do echo "Releasing $id" mvnq -DstagingRepositoryId="$id" nexus-staging:rc-release done done