forked from holatuwol/liferay-intellij
-
Notifications
You must be signed in to change notification settings - Fork 0
/
intellij_common
executable file
·308 lines (224 loc) · 7.36 KB
/
intellij_common
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#!/bin/bash
cachefolder() {
timeecho "Building ${PWD} ls-files cache to speed up directory scanning"
find modules -type f \
-not -path '*/build/*' \
-not -path '*/classes/*' \
-not -path '*/node_modules/*' \
-not -path '*/node_modules_cache/*' \
> modules/git_ls_files_modules.txt
}
cachemodules() {
for folder in $@; do
if [ ! -d "${folder}" ] || [ ! -d "${folder}/modules" ]; then
continue
fi
pushd "${folder}" > /dev/null
cachefolder
popd > /dev/null
done
if [ -d modules ]; then
cachefolder
fi
}
checknode() {
NODEJS=$(which nodejs 2> /dev/null)
if [ "" == "${NODEJS}" ]; then
NODEJS=$(which node 2> /dev/null)
fi
if [ "" == "${NODEJS}" ]; then
timeecho "Please install node.js"
exit 1
fi
local NPM=$(which npm 2> /dev/null)
if [ "" == "${NPM}" ]; then
timeecho "Please install npm"
exit 1
fi
local SCRIPT_ROOT="$(dirname "${BASH_SOURCE[0]}")"
pushd "${SCRIPT_ROOT}" > /dev/null
checknodemodules
popd > /dev/null
}
checknodemodules() {
node --version > node.version.new
if [ -f node.version.old ]; then
if [ "$(cat node.version.old)" != "$(cat node.version.new)" ]; then
rm -rf node_modules
fi
rm node.version.old
else
rm -rf node_modules
fi
mv node.version.new node.version.old
local NPM_MAJOR_VERSION=$(npm --version | cut -d'.' -f 1)
local NPM_MINOR_VERSION=$(npm --version | cut -d'.' -f 2)
if [[ ${NPM_MAJOR_VERSION} -lt 5 ]]; then
timeecho 'Running npm install to update script dependencies'
npm install
elif [[ ${NPM_MAJOR_VERSION} -eq 5 ]] && [[ ${NPM_MINOR_VERSION} -lt 7 ]]; then
timeecho 'Running npm install to update script dependencies'
npm install
else
timeecho 'Running npm ci to update script dependencies'
rm -f npm-shrinkwrap.json
npm ci
git checkout npm-shrinkwrap.json > /dev/null
fi
}
copylibs() {
if [ ! -d modules ]; then
return 0
fi
if [ -d ../liferay-binaries-cache-2017 ] && [ -d ../liferay-binaries-cache-2020 ]; then
return 0
fi
if [ -d ../liferay-binaries-cache-2017 ] || [ -d ../liferay-binaries-cache-2020 ]; then
if [ -d ../liferay-binaries-cache-2017 ]; then
timeecho 'Missing clone of https://github.com/liferay/liferay-binaries-cache-2020'
timeecho 'Some dependency libraries may be missing if they are present in liferay-binaries-cache-2017 but not liferay-binaries-cache-2020'
else
timeecho 'Missing clone of https://github.com/liferay/liferay-binaries-cache-2017'
timeecho 'Some dependency libraries may be missing if they are present in liferay-binaries-cache-2020 but not liferay-binaries-cache-2017'
fi
return 0
fi
timeecho 'Missing clone of https://github.com/liferay/liferay-binaries-cache-2017'
timeecho 'Missing clone of https://github.com/liferay/liferay-binaries-cache-2020'
if [ "" == "$(which mvn)" ]; then
timeecho 'Maven is not available in the path, dependency libraries will be missing'
return 1
fi
timeecho 'Retrieving dependency libraries using Maven'
"${NODEJS}" "${SCRIPT_FOLDER}/bin/pom.js" "${PWD}"
mvn --fail-at-end dependency:go-offline
grep '<module>.*</module>' pom.xml | awk -F'[<>]' '{ print $3 "/pom.xml" }' | xargs rm
rm pom.xml
for folder in development global portal; do
if [ ! -f lib/$folder/dependencies.properties ]; then
continue
fi
for dependency in $(cat lib/$folder/dependencies.properties); do
local lib_jar=lib/$folder/$(echo $dependency | cut -d'=' -f 1).jar
local group_maven=$(echo $dependency | cut -d'=' -f 2 | cut -d':' -f 1 | tr '.' '/')
local name=$(echo $dependency | cut -d'=' -f 2 | cut -d':' -f 2)
local version=$(echo $dependency | cut -d'=' -f 2 | cut -d':' -f 3)
local maven_path=$HOME/.m2/repository/${group_maven}/${name}/${version}/${name}-${version}.jar
if [ -f $maven_path ]; then
cp $maven_path $lib_jar
continue
fi
done
done
}
enabledebug() {
if [ -f .idea/workspace.xml ] && [ "" != "$(grep -F RunManager .idea/workspace.xml)" ]; then
return 0
fi
local SCRIPT_ROOT="$(dirname "${BASH_SOURCE[0]}")"
if [ -d .idea/runConfigurations ]; then
return 0
fi
mkdir -p .idea/runConfigurations
cp -f ${SCRIPT_ROOT}/localhost_8000.xml .idea/runConfigurations/
}
ignoreiml() {
if [ -d .git ] || [ -f .git ]; then
git ls-files | grep '\(\.idea\|\.iml\)' | xargs git update-index --assume-unchanged
fi
}
licensing() {
if [ ! -e .git ]; then
return 0
fi
if [ -d modules/apps/static/portal-license/portal-license-enterprise-app ]; then
return 0
fi
local APP_VERSION=$(grep build.portal.license.enterprise.app.module.version= build.properties | cut -d'=' -f 2)
if [ "" == "${APP_VERSION}" ]; then
return 0
fi
local UPSTREAM_REMOTE=$(git remote -v | grep -F ':liferay/liferay-portal-ee' | awk '{ print $1 }')
if [ "" == "${UPSTREAM_REMOTE}" ]; then
return 0
fi
local UPSTREAM_BRANCH=$(git for-each-ref "refs/remotes/${UPSTREAM_REMOTE}/7.1.x")
if [ "" == "${UPSTREAM_BRANCH}" ]; then
return 0
fi
local APP_COMMIT=$(git log "${UPSTREAM_BRANCH}" --pretty='%H' --grep=" ${APP_VERSION} prep next$" -- modules/apps/static/portal-license/portal-license-enterprise-app/bnd.bnd)
if [ "" == "${APP_COMMIT}" ]; then
return 0
fi
git checkout ${APP_COMMIT} -- modules/apps/static/portal-license/portal-license-enterprise-app/
}
setantopts() {
JAVA_VERSION=$(java -version 2>&1 | head -1 | cut -d'"' -f 2 | cut -d'.' -f 2)
ANT_OPTS='-Xms2g -Xmx2g'
if [[ 8 -gt $JAVA_VERSION ]]; then
ANT_OPTS="${ANT_OPTS} -XX:MaxPermSize=1g"
fi
export ANT_OPTS
}
setuplibs() {
rm -rf .idea/libraries
if [ ! -f build.xml ]; then
return 0
fi
local NEEDS_SETUP_LIBS=
for folder in development global portal; do
if [ -f "lib/$folder/dependencies.properties" ] && [[ $(ls -1 lib/$folder/ | grep -c '\.jar$') -lt $(cat "lib/$folder/dependencies.properties" | wc -l) ]]; then
NEEDS_SETUP_LIBS=true
fi
done
if [ "" == "${NEEDS_SETUP_LIBS}" ]; then
return 0
fi
setantopts
timeecho 'Running ant setup-libs to initialize portal libraries'
ant setup-libs
}
setupsdk() {
if [ ! -f build.xml ] || [ ! -d modules ] || [ -d tools/sdk ]; then
return 0
fi
setantopts
timeecho 'Running ant setup-sdk to initialize gradle configuration'
ant setup-sdk
}
setupwork() {
if [ -d portal-impl ] || [ ! -f build-working-dir.xml ]; then
return 0
fi
local LOCAL_BRANCH=$(grep -o '`[^`]*`' "README.markdown" | cut -d'`' -f 2 | uniq)
if [ "" == "${LOCAL_BRANCH}" ]; then
LOCAL_BRANCH=7.0.x
fi
local UPSTREAM_BRANCH=$(git for-each-ref --format='%(refname)' refs/remotes/ | grep "/upstream[^/]*/$LOCAL_BRANCH$" | cut -d'/' -f 3,4)
local WORKING_DIR_HASH=$(cat git-commit-portal)
git merge-base $UPSTREAM_BRANCH $WORKING_DIR_HASH > /dev/null
if [[ 0 -ne $? ]]; then
timeecho "Specified $LOCAL_BRANCH hash not available, fetching latest $UPSTREAM_BRANCH"
git fetch --no-tags $(echo $UPSTREAM_BRANCH | tr '/' ' ')
fi
ant -f build-working-dir.xml
}
timeecho() {
echo '['$(date '+%H:%M:%S')']' $@
}
uncachemodules() {
for folder in $@; do
if [ ! -d "${folder}" ]; then
continue
fi
rm -f ${folder}/modules/git_ls_files_modules.txt
done
rm -f modules/git_ls_files_modules.txt
}
setupwork
if [ ! -d portal-impl ]; then
timeecho 'Unable to find portal-impl folder, the current working directory does not appear to be the portal source'
timeecho 'Please navigate to the portal source folder and then re-run your command'
timeecho 'Note: additional arguments are additional source roots (blade workspaces, subrepositories, plugins SDK, etc.)'
exit 1
fi