-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmvn.sh
More file actions
executable file
·87 lines (74 loc) · 2.58 KB
/
mvn.sh
File metadata and controls
executable file
·87 lines (74 loc) · 2.58 KB
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
# MAVEN
# export MAVEN_OPTS="$JAVA_OPTS -noverify -Xmx1048m -XX:+TieredCompilation -XX:TieredStopAtLevel=1"
# use project specific
# ${PROJECT_ROOT}/.mvn/jvm.config (MAVEN_OPTS replacement, jvm options)
# ${PROJECT_ROOT}/.mvn/maven.config (mvn command line arguments [without the mvn itself])
alias mvn-all-no-test='mvn clean install -DskipTests'
alias mvn-all-no-it='mvn clean install -DskipITs'
alias mvn-all-no-test-no-it='mvn clean install -DskipTests -DskitITs -Dmaven.test.skip=true'
alias mvn-all='mvn clean install'
alias mvn-remote-debug='MAVEN_OPTS="$MAVEN_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 -Xnoagent -Djava.compiler=NONE" mvn'
alias mvn-cleaner="${SCRIPT_BASE_DIR}/utils/mvn-cleaner.sh"
alias mvn-search="${SCRIPT_BASE_DIR}/utils/mvn-search.sh"
# functions
# $1 = plugin name in format: "groupId:artifactId"
mvn_get_plugin_description() {
mvn help:describe -Dplugin=$1 2>/dev/null | grep -v '^\[[IWE]'
}
# $1 = plugin description
mvn_get_plugin_prefix() {
echo "$1" | sed -n '/^Goal Prefix: /s/^Goal Prefix: \(.*\)/\1/p'
}
# $1 = prefix (optional)
# $2 = plugin description
mvn_get_plugin_goals() {
local prefix
local description
if [ $# -eq 1 ]; then
prefix=$(mvn_get_plugin_prefix "$1")
description="$1"
else
prefix=$1
description="$2"
fi
echo "$description" | sed -n "/^${prefix}:/s/^${prefix}:\(.*\)/\1/p"
}
# mvn-gen-pom [-t <template>] [groupId] [artifactId] [version]
# mvn-gen-pom [-t <template>] [groupId:artifactId] [version]
# mvn-gen-pom [-t <template>] [groupId] [artifactId:version]
# mvn-gen-pom [-t <template>] [groupId:artifactId:version]
mvn-gen-pom() {
template="default"
gav=()
while [ ! -z "$1" ]; do
if [ "$1" == "-t" ]; then
shift
if [ ! -z "$1" ]; then
template=$1
shift
else
echo "argument -t need a parameter" >&2
return 1
fi
fi
with_colon="$1"
while [[ "$with_colon" =~ : ]]; do
first_part="${with_colon%%:*}"
gav+=("$first_part")
with_colon="${with_colon#*:}"
done
gav+=("$with_colon")
shift
done
params=()
if [ ! -z "${gav[0]}" ]; then
params+=("-e" "s/{var:groupId}/${gav[0]}/")
fi
if [ ! -z "${gav[1]}" ]; then
params+=("-e" "s/{var:artifactId}/${gav[1]}/")
fi
if [ ! -z "${gav[2]}" ]; then
params+=("-e" "s/{var:version}/${gav[2]}/")
fi
sed ${params[@]} "${HOME}/.m2/templates/${template}"
}