-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrcp-newproject.sh
executable file
·137 lines (116 loc) · 3.14 KB
/
rcp-newproject.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
function usage {
cat <<- EOT
Create an empty Tycho project.
usage : $0 [[-d directory] [-p package] [-n name] [--tycho]] [-h]
-d --destination directory
-p --package Name of the based package of the Eclipse RCP application
-n --name Name of the application
--tycho Defined the version of Tycho: 0.12.0, 0.13.0 and 0.14.1 are supported. 0.14.1 is the default value.
-h --help Display this message
EOT
}
#-------------------------------------------------------------------------------
# Cleanup temporary file in case of keyboard interrupt or termination signal.
#-------------------------------------------------------------------------------
function cleanup_temp_file {
# TODO
exit 0
}
trap cleanup_temp_file SIGHUP SIGINT SIGPIPE SIGTERM
folder=
package=
title=
tycho_version=0.14.1
while [ $# -gt 0 ]; do
case $1 in
-d | --destination )
shift
folder=$1
;;
-p | --package )
shift
package=$1
;;
-n | --name )
shift
title=$1
;;
--tycho )
shift
tycho_version=$1
;;
-h | --help )
usage
exit
;;
* )
usage
exit 1
esac
shift
done
# Checking arguments
if [[ $folder == "" || $package == "" || $title == "" ]]
then
usage
exit 1
fi
echo "[0/5] Building project"
echo "[1/5] Creating target structure"
if [ ! -d "$folder" ]
then
mkdir $folder 2> /dev/null
if [ $? -ne 0 ]
then
echo "[ERROR] The destination is not a directory"
exit 1
fi
fi
mkdir $folder/$package/{icons,META-INF,src} -p
IFS=. read -r -a packages <<< $package
fullDir=$folder/$package/src/
for subpackage in $packages; do
fullDir="$fullDir$subpackage/"
done
mkdir $fullDir -p
mkdir $folder/$package.parent
mkdir $folder/$package.target
mkdir $folder/$package.product
echo "[2/5] Building Eclipse Plug-In Project"
files="bundle/plugin.xml
bundle/.classpath
bundle/.project
bundle/build.properties
bundle/META-INF/MANIFEST.MF
bundle/pom.xml
bundle/plugin_customization.ini"
for file in $files; do
echo "Processing $file"
sed "s/{{ RCP_PACKAGE }}/$package/g" < $file | sed "s/{{ RCP_TITLE }}/$title/g" > $folder/$package/${file:7}
done
files=bundle/src/*
for file in $files ;do
echo "Processing $file"
sed "s/{{ RCP_PACKAGE }}/$package/g" < $file | sed "s/{{ RCP_TITLE }}/$title/g" > $fullDir/${file:11}
done
echo "[3/5] Building Parent Project"
files="parent/pom.xml"
for file in $files; do
echo "Processing $file"
sed "s/{{ RCP_PACKAGE }}/$package/g" < $file | sed "s/{{ RCP_TITLE }}/$title/g" | sed "s/{{ TYCHO_VERSION }}/$tycho_version/g" > $folder/$package.parent/${file:7}
done
echo "[4/5] Building Target Project"
files="target/pom.xml
target/indigo.target"
for file in $files; do
echo "Processing $file"
sed "s/{{ RCP_PACKAGE }}/$package/g" < $file | sed "s/{{ RCP_TITLE }}/$title/g" > $folder/$package.target/${file:7}
done
echo "[5/5] Building Product Project"
files="product/pom.xml
product/product.product"
for file in $files; do
echo "Processing $file"
sed "s/{{ RCP_PACKAGE }}/$package/g" < $file | sed "s/{{ RCP_TITLE }}/$title/g" > $folder/$package.product/${file:8}
done