-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmvnbuild
88 lines (62 loc) · 1.98 KB
/
mvnbuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# Check pom.xml exists
if [ -f "./pom.xml" ]; then
# Ckeck argument
if [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Replace version
echo "Replacing @version in java code...."
sed -i -e "s/\
^ \* @version [0-9]\+\.[0-9]\+\.[0-9]\+\
/ * @version ${1}/gm" $( \
grep -lr --include="*.java" \
"^ \* @version [0-9]\+\.[0-9]\+\.[0-9]\+" \
src/main/java \
)
echo "Replaced files:"
grep -lr --include="*.java" \
"^ \* @version [0-9]\+\.[0-9]\+\.[0-9]\+" \
src/main/java
echo "Replacing version in pom.xml...."
sed -i -e "1,/\
<[[:space:]]*version[[:space:]]*>\
[[:space:]]*[0-9]\+\.[0-9]\+\.[0-9]\+[[:space:]]*\
<[[:space:]]*\/[[:space:]]*version[[:space:]]*>\
/s/\
<[[:space:]]*version[[:space:]]*>\
[[:space:]]*[0-9]\+\.[0-9]\+\.[0-9]\+[[:space:]]*\
<[[:space:]]*\/[[:space:]]*version[[:space:]]*>\
/<version>${1}<\/version>/m" pom.xml
echo "Replaced pom.xml."
# Build
echo "Cleaning build directory...."
mvn clean
echo "Cleaned build directory."
echo "Starting building...."
mvn package
echo "Finished building."
# For Library
echo -n \
"Do you want to make repository and generate javadoc? [Y/n]: "
read genRepoAndDoc
case $genRepoAndDoc in
"" | [Yy]* )
echo "Starting making repository...."
mvn deploy
echo "Finished making repository."
echo "Starting generating javadoc...."
mvn javadoc:javadoc
echo "Finished generating javadoc."
;;
* )
echo "Building has been cancelled."
;;
esac
elif [ -z $1 ]; then
echo "Please append version."
else
echo \
"Version should be in [number].[number].[number] format."
fi
else
echo "Run in the same directory as pom.xml."
fi