Coder Social home page Coder Social logo

javanibble / maven-release-plugin-example Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 2.0 7 KB

The following repository contains an example of a Spring Boot application that makes use of the Maven Release Plugin to deploy snapshot versions to a Snapshot Repository on PackageCloud and also the release artefacts within the Release Repository on PackageCloud.

Java 100.00%
spring-boot maven maven-plugin release packagecloud maven-release-plugin maven-release

maven-release-plugin-example's Introduction

SpringBoot Application: Maven Release Plugin Example

The following repository contains an example of a SpringBoot application that makes use of the Maven Release Plugin to deploy snapshot versions to a Snapshot Repository on PackageCloud and also the release artifacts within the Release Repository on PackageCloud.

Maven Release Plugin

Goal: Prepare Release

The goal release:prepare prepares for a release in SCM. Preparing a release goes through the following release phases:

  • Check that there are no uncommitted changes in the sources
  • Check that there are no SNAPSHOT dependencies
  • Change the version in the POMs from x-SNAPSHOT to a new version (you will be prompted for the versions to use)
  • Transform the SCM information in the POM to include the final destination of the tag
  • Run the project tests against the modified POMs to confirm everything is in working order
  • Commit the modified POMs
  • Tag the code in the SCM with a version name (this will be prompted for)
  • Bump the version in the POMs to a new value y-SNAPSHOT (these values will also be prompted for)
  • Commit the modified POMs
$ mvn clean release:prepare

Goal: Perform Release

The goal release:perform performs a release from SCM, either from a specified tag, or the tag representing the previous release in the working copy created by release:prepare. Performing a release runs the following release phases:

  • Checkout from an SCM URL with optional tag
  • Run the predefined Maven goals to release the project (by default, deploy site-deploy)
$ mvn clean release:perform

Goal: Rollback Release

The goal release:rollback rollbacks changes made by a previous release. This requires that the previous release descriptor release.properties is still available in the local working copy.

$ mvn clean release:rollback

Goal: Clean Release

The goal release:clean cleans up after a release preparation. This is done automatically after a successful release:perform, so is best served for cleaning up a failed or abandoned release, or a dry run.

$ mvn clean release:clean

PackageCloud Repositories

A software repository, or “repo” for short, is a storage location for software packages. PackageCloud is a software repository that supports most popular package types, from Java to Python to Ruby and Node, and more.

For this example, I will use PackageCloud as a maven repository to store the snapshot and release artifacts of this project.

To setup a free account on PackageCloud, use the following link.

The following two repositories were created to host the snapshot artifacts and the release artifacts.

Maven Setup

After you have created a Snapshot & Release repository on PackageCloud, it is important also to setup maven to connect to these repositories. PackageCloud provides an API-Token that is used for maven to authenticate with PackageCloud.

Step 1: Add the API Token to the maven settings file located at $HOME/.m2/settings.xml

<server>
        <id>packagecloud.snapshot</id>
        <password>{{ PASTE API TOKEN HERE }}</password>
</server>
<server>
        <id>packagecloud.release</id>
        <password>{{ PASTE API TOKEN HERE }}</password>
</server>

Step 2: Add the dependency to the section of your project'spom.xml.

<build>
  <extensions>
    <extension>
      <groupId>io.packagecloud.maven.wagon</groupId>
      <artifactId>maven-packagecloud-wagon</artifactId>
      <version>0.0.6</version>
    </extension>
  </extensions>
</build>

Step 3: Configure your project's to point to your packagecloud.io repository,

<distributionManagement>
    <repository>
        <id>packagecloud.release</id>
        <url>packagecloud+https://packagecloud.io/javanibble/release</url>
    </repository>
    <snapshotRepository>
        <id>packagecloud.snapshot</id>
        <url>packagecloud+https://packagecloud.io/javanibble/snapshot</url>
    </snapshotRepository>
</distributionManagement>

Compile and Run the Application

Use the following command to compile the SpringBoot application and deploy the snapshot version of the JAR artifact to the PackageCloud snapshot repository.

Build & Deploy Application

The following command will build the SpringBoot application and then deploy the snapshot version to the PackageCloud Java Nibble Snapshot Repository.

$ mvn clean deploy

Release Application

The following command will run maven in batch mode and will not accept input from the user. It will run the release:prepare and release:perform goals.

$ mvn clean --batch-mode release:prepare release:perform

The following command will run maven in batch mode passing the Release Version and Development Version as system properties. It also specify the tag name in your SCM.

$ mvn clean --batch-mode release:prepare -Dtag=SpringBootMavenReleasePlugin-1.0.0 -DreleaseVersion=1.0.0 -DdevelopmentVersion=1.0.1-SNAPSHOT

Summary

Congratulations! You have successfully deployed the snapshot artifacts to a snapshot repo and also performed a release and deployed the released artifact to a release repo. Follow me on any of the different social media platforms and feel free to leave comments.

maven-release-plugin-example's People

Forkers

deltacypher ggutu

maven-release-plugin-example's Issues

Git push command failed.

Hi javanibble,

I am trying your code for my project but I get the git push error, can you please help to fix this issue.
I am getting an error which mention below.

[�[1;31mERROR�[m] Failed to execute goal �[32morg.apache.maven.plugins:maven-release-plugin:2.5.3:prepare�[m �[1m(default-cli)�[m on project �[36mSpringBootMavenReleasePlugin�[m: �[1;31mUnable to commit files�[m
[�[1;31mERROR�[m] �[1;31mProvider message:�[m
[�[1;31mERROR�[m] �[1;31mThe git-push command failed.�[m
[�[1;31mERROR�[m] �[1;31mCommand output:�[m
[�[1;31mERROR�[m] �[1;31mfatal: could not read Username for 'https://github.com/': No such device or address�[m
[�[1;31mERROR�[m] �[1;31m�[m
[�[1;31mERROR�[m]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.