Using Maven Versions Plugin

Issue: BAEL-2191
This commit is contained in:
Andrea Ligios 2018-10-09 20:47:03 +02:00 committed by Josh Cummings
parent fb6a1a0855
commit 50c281d9be
3 changed files with 226 additions and 0 deletions

View File

@ -0,0 +1,76 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>versions-maven-plugin-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<commons-compress-version>1.15</commons-compress-version>
</properties>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>${commons-compress-version}</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<excludes>
<exclude>org.apache.commons:commons-collections4</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>apache.snapshots</id>
<name>Apache Development Snapshot Repository</name>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>

View File

@ -0,0 +1,76 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>versions-maven-plugin-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<commons-compress-version>1.15</commons-compress-version>
</properties>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>${commons-compress-version}</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<excludes>
<exclude>org.apache.commons:commons-collections4</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>apache.snapshots</id>
<name>Apache Development Snapshot Repository</name>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>

View File

@ -0,0 +1,74 @@
#!/bin/bash
#function to display commands
exe() { echo -e "\$ $@\n" ; "$@" ; }
TEXT_COLOR='\033[1;33m' #Yellow
NO_COLOR='\033[0m' # No Color
clear
echo -e "======================================================================================"
echo -e " Showcase for the BAELDUNG tutorial \"Use the latest version of a dependency in Maven\""
echo -e " Author: Andrea Ligios"
echo -e "======================================================================================"
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
echo -e " Resetting the demo environment (which will be altered during the run): "
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
rm -f pom.xml.versionsBackup
cp original/pom.xml pom.xml
ls -lt pom.*
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
echo -e " Checking for newer versions of the Maven dependencies:"
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
exe mvn versions:display-dependency-updates
echo
read -p "Press enter to continue"
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
echo -e " Updating SNAPSHOT dependencies to their RELEASE version, if any:"
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
exe mvn versions:use-releases
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
echo -e " A backup has been created automatically:"
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
ls -lt pom.*
echo
read -p "Press enter to continue"
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
echo -e " Updating RELEASE dependencies to their *next* RELEASE version:"
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
exe mvn versions:use-next-releases
echo
read -p "Press enter to continue"
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
echo -e " Reverting every modification made since the beginning:"
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
exe mvn versions:revert
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
echo -e " The backup is gone, and the pom.xml contains the initial dependencies:"
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
ls -lt pom.*
echo
read -p "Press enter to continue"
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
echo -e " Updating RELEASE dependencies to their *latest* RELEASE version:"
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
exe mvn versions:use-latest-releases
echo
read -p "Press enter to continue"
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
echo -e " Committing the modifications to pom.xml:"
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
exe mvn versions:commit
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
echo -e " The backup is gone, and the pom.xml contains the latest dependencies:"
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
ls -lt pom.*
echo
echo -e "${TEXT_COLOR}\nThat's all folks!${NO_COLOR}\n"