Skip to content

Commit 50c281d

Browse files
andrea-ligiosjzheaux
authored andcommitted
Using Maven Versions Plugin
Issue: BAEL-2191
1 parent fb6a1a0 commit 50c281d

3 files changed

Lines changed: 226 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.baeldung</groupId>
6+
<artifactId>versions-maven-plugin-example</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
9+
<properties>
10+
<commons-compress-version>1.15</commons-compress-version>
11+
</properties>
12+
13+
<dependencies>
14+
15+
<dependency>
16+
<groupId>commons-io</groupId>
17+
<artifactId>commons-io</artifactId>
18+
<version>2.3</version>
19+
</dependency>
20+
21+
<dependency>
22+
<groupId>org.apache.commons</groupId>
23+
<artifactId>commons-collections4</artifactId>
24+
<version>4.0</version>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.apache.commons</groupId>
29+
<artifactId>commons-lang3</artifactId>
30+
<version>3.0</version>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>org.apache.commons</groupId>
35+
<artifactId>commons-compress</artifactId>
36+
<version>${commons-compress-version}</version>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>commons-beanutils</groupId>
41+
<artifactId>commons-beanutils</artifactId>
42+
<version>1.9.1-SNAPSHOT</version>
43+
</dependency>
44+
45+
</dependencies>
46+
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.codehaus.mojo</groupId>
51+
<artifactId>versions-maven-plugin</artifactId>
52+
<version>2.7</version>
53+
<configuration>
54+
<excludes>
55+
<exclude>org.apache.commons:commons-collections4</exclude>
56+
</excludes>
57+
</configuration>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
62+
<repositories>
63+
<repository>
64+
<id>apache.snapshots</id>
65+
<name>Apache Development Snapshot Repository</name>
66+
<url>https://repository.apache.org/content/repositories/snapshots/</url>
67+
<releases>
68+
<enabled>false</enabled>
69+
</releases>
70+
<snapshots>
71+
<enabled>true</enabled>
72+
</snapshots>
73+
</repository>
74+
</repositories>
75+
76+
</project>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.baeldung</groupId>
6+
<artifactId>versions-maven-plugin-example</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
9+
<properties>
10+
<commons-compress-version>1.15</commons-compress-version>
11+
</properties>
12+
13+
<dependencies>
14+
15+
<dependency>
16+
<groupId>commons-io</groupId>
17+
<artifactId>commons-io</artifactId>
18+
<version>2.3</version>
19+
</dependency>
20+
21+
<dependency>
22+
<groupId>org.apache.commons</groupId>
23+
<artifactId>commons-collections4</artifactId>
24+
<version>4.0</version>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.apache.commons</groupId>
29+
<artifactId>commons-lang3</artifactId>
30+
<version>3.0</version>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>org.apache.commons</groupId>
35+
<artifactId>commons-compress</artifactId>
36+
<version>${commons-compress-version}</version>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>commons-beanutils</groupId>
41+
<artifactId>commons-beanutils</artifactId>
42+
<version>1.9.1-SNAPSHOT</version>
43+
</dependency>
44+
45+
</dependencies>
46+
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.codehaus.mojo</groupId>
51+
<artifactId>versions-maven-plugin</artifactId>
52+
<version>2.7</version>
53+
<configuration>
54+
<excludes>
55+
<exclude>org.apache.commons:commons-collections4</exclude>
56+
</excludes>
57+
</configuration>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
62+
<repositories>
63+
<repository>
64+
<id>apache.snapshots</id>
65+
<name>Apache Development Snapshot Repository</name>
66+
<url>https://repository.apache.org/content/repositories/snapshots/</url>
67+
<releases>
68+
<enabled>false</enabled>
69+
</releases>
70+
<snapshots>
71+
<enabled>true</enabled>
72+
</snapshots>
73+
</repository>
74+
</repositories>
75+
76+
</project>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
#function to display commands
3+
exe() { echo -e "\$ $@\n" ; "$@" ; }
4+
5+
TEXT_COLOR='\033[1;33m' #Yellow
6+
NO_COLOR='\033[0m' # No Color
7+
8+
clear
9+
10+
echo -e "======================================================================================"
11+
echo -e " Showcase for the BAELDUNG tutorial \"Use the latest version of a dependency in Maven\""
12+
echo -e " Author: Andrea Ligios"
13+
echo -e "======================================================================================"
14+
15+
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
16+
echo -e " Resetting the demo environment (which will be altered during the run): "
17+
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
18+
rm -f pom.xml.versionsBackup
19+
cp original/pom.xml pom.xml
20+
ls -lt pom.*
21+
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
22+
echo -e " Checking for newer versions of the Maven dependencies:"
23+
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
24+
exe mvn versions:display-dependency-updates
25+
echo
26+
read -p "Press enter to continue"
27+
28+
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
29+
echo -e " Updating SNAPSHOT dependencies to their RELEASE version, if any:"
30+
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
31+
exe mvn versions:use-releases
32+
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
33+
echo -e " A backup has been created automatically:"
34+
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
35+
ls -lt pom.*
36+
echo
37+
read -p "Press enter to continue"
38+
39+
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
40+
echo -e " Updating RELEASE dependencies to their *next* RELEASE version:"
41+
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
42+
exe mvn versions:use-next-releases
43+
echo
44+
read -p "Press enter to continue"
45+
46+
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
47+
echo -e " Reverting every modification made since the beginning:"
48+
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
49+
exe mvn versions:revert
50+
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
51+
echo -e " The backup is gone, and the pom.xml contains the initial dependencies:"
52+
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
53+
ls -lt pom.*
54+
echo
55+
read -p "Press enter to continue"
56+
57+
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
58+
echo -e " Updating RELEASE dependencies to their *latest* RELEASE version:"
59+
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
60+
exe mvn versions:use-latest-releases
61+
echo
62+
read -p "Press enter to continue"
63+
64+
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
65+
echo -e " Committing the modifications to pom.xml:"
66+
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
67+
exe mvn versions:commit
68+
echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------"
69+
echo -e " The backup is gone, and the pom.xml contains the latest dependencies:"
70+
echo -e "--------------------------------------------------------------------------------------${NO_COLOR}"
71+
ls -lt pom.*
72+
echo
73+
74+
echo -e "${TEXT_COLOR}\nThat's all folks!${NO_COLOR}\n"

0 commit comments

Comments
 (0)