forked from jbossas/archetypes
-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate-blank.sh
executable file
·124 lines (96 loc) · 2.37 KB
/
generate-blank.sh
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
set -o errexit
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# DEFINE
ARCHETYPES="jboss-javaee6-webapp-archetype jboss-javaee6-webapp-ear-archetype"
# SCRIPT
usage()
{
HUMAN_READABLE_ARCHETYPES=""
i=0
for archetype in $ARCHETYPES
do
if [ $i -ne 0 ]
then
HUMAN_READABLE_ARCHETYPES="${HUMAN_READABLE_ARCHETYPES}, "
fi
echo ""
HUMAN_READABLE_ARCHETYPES="${HUMAN_READABLE_ARCHETYPES}${archetype}"
i=$[$i+1]
done
cat << EOF
usage: $0 options
This script generates a "blanked" version of an archetype.
The name of archetype directory must match the artifactId of the archetype. Arcehtypes are placed in $DIR with the suffix -blank
OPTIONS:
-a Generate a blank archetype for all archetypes, currently ${HUMAN_READABLE_ARCHETYPES}
-n The name of the archetype to blank.
-c Removes the blank archetypes
-h Shows this message
EOF
}
clean()
{
echo "**** Cleaning $DIR/*-blank-archetype"
rm -rf $DIR/*-blank-archetype
}
blank()
{
ARCHETYPE_NAME=$1
ARCHETYPE_BLANK_NAME=${ARCHETYPE_NAME//archetype/blank-archetype}
ARCHETYPE_DIR=${DIR}/${ARCHETYPE_NAME}
ARCHETYPE_BLANK_DIR="${DIR}/${ARCHETYPE_BLANK_NAME}"
cat << EOF
**** Generating blank version of ${ARCHETYPE_NAME} into ${ARCHETYPE_BLANK_DIR}
**** Blank artifactId is ${ARCHETYPE_BLANK_NAME}
EOF
rm -rf ${ARCHETYPE_BLANK_DIR}
cp -r ${ARCHETYPE_DIR} ${ARCHETYPE_BLANK_DIR}
cd $ARCHETYPE_BLANK_DIR
mv src/main/resources/META-INF/maven/archetype-metadata-blank.xml src/main/resources/META-INF/maven/archetype-metadata.xml
perl -pi -e "s/${ARCHETYPE_NAME}/${ARCHETYPE_BLANK_NAME}/g" `find . -name pom.xml`
}
ALL=0
CLEAN=0
while getopts “ahcn:” OPTION
do
case $OPTION in
a)
ALL=1
;;
h)
usage
exit
;;
c)
clean
CLEAN=1
;;
n)
NAME=$OPTARG
;;
[?])
usage
exit
;;
esac
done
if [ $ALL -eq 1 ]
then
for archetype in $ARCHETYPES
do
blank $archetype
done
else
if [ -z "$NAME"] && [ $CLEAN -ne 1 ]
then
echo "No archetype name defined"
usage
exit
elif [ -n "$NAME" ]
then
blank $NAME
fi
fi