-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·336 lines (270 loc) · 13.3 KB
/
run.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
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#!/bin/sh
mcfversion=$2
mcfdist=$3
mcfdisturl=$4
initLocal() {
echo "Starting Apache ManifoldCF SDK initialization for version $mcfversion - Init Local"
mcfversionInFuction=$1
echo "Init - 1 - MCF version = $1"
mcfdistInFunction=$2
echo "Init - 2 - MCF DIST URL = $2"
mcfdistTypeInFunction=$3
echo "Init - 3 - MCF DIST TYPE = $3"
echo "Updating the ManifoldCF version inside the pom.xml"
mvn versions:set-property -Dproperty=manifoldcf.version -DnewVersion=$mcfversionInFuction
echo "Creating Docker Volume for the ManifoldCF Maven Repository"
docker volume create --name mcf-maven-repo
echo "Creating Docker Volume for the ManifoldCF Installation..."
docker volume create --name mcf-app-volume
echo "Creating simlink for the local MCF source code repository: $mcfdistInFunction"
mkdir target
cd target
ln -s $mcfdistInFunction mcf-local
cd ..
echo "Building the Docker Container for executing Ant and Maven build..."
docker build src/main/docker-local -t mcf-sdk-init
echo "Copying local source code into the container..."
docker run -itd --rm --name mcf-sdk-init-container -v mcf-maven-repo:/root/.m2 -v mcf-app-volume:/usr/src/manifoldcf -t mcf-sdk-init bash
docker cp target/mcf-local/. mcf-sdk-init-container:/usr/src/manifoldcf
docker stop mcf-sdk-init-container
echo "Starting the mcf-sdk-build-container for executing the Maven and Ant building process..."
docker run -it --rm --name mcf-sdk-init-container -v mcf-maven-repo:/root/.m2 -v mcf-app-volume:/usr/src/manifoldcf -t mcf-sdk-init /bin/bash -c "ant make-core-deps make-deps image; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-api-service -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-api-service.war; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-authority-service -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-authority-service.war; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-combined-service -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-combined-service.war; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-crawler-ui -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-crawler-ui.war
mvn -B -e -T 1C clean install -DskipTests -DskipITs"
echo "Starting the mcf-sdk-init-container to export the Maven repository in target/mcf-maven-repo..."
docker run --rm --name mcf-sdk-init-container -itd -v mcf-maven-repo:/root/.m2 -v mcf-app-volume:/usr/src/manifoldcf -t mcf-sdk-init bash
echo "Copying the ManifoldCF Maven Repo in target/mcf-maven-repo..."
mkdir target
docker cp mcf-sdk-init-container:/root/.m2/repository target/mcf-maven-repo
mkdir target/mcf-dist
echo "Copying the mcf-dist in target/mcf-dist"
docker cp mcf-sdk-init-container:/usr/src/manifoldcf/dist/apache-manifoldcf-$mcfdistInFunction-dev-bin.tar.gz target/mcf-dist
tar -xvz target/mcf-dist/apache-manifoldcf-$mcfdistInFunction-dev-bin.tar.gz -C target/mcf-dist
rm apache-manifoldcf-$mcfdistInFunction-dev-bin.tar.gz
echo "Stopping and removing the existent building container..."
docker stop mcf-sdk-init-container
#echo "Merging the ManifoldCF Maven Repository with the local Maven Repo"
#cp -n target/mcf-maven-repo $HOME/.m2
}
init226() {
echo "Starting Apache ManifoldCF SDK initialization for version $mcfversion - Init 2.26"
mcfversionInFuction=$1
echo "Init - 1 - MCF version = $1"
mcfdistInFunction=$2
echo "Init - 2 - MCF DIST URL = $2"
mcfdistTypeInFunction=$3
echo "Init - 3 - MCF DIST TYPE = $3"
echo "Updating the ManifoldCF version inside the pom.xml"
mvn versions:set-property -Dproperty=manifoldcf.version -DnewVersion=$mcfversionInFuction
echo "Creating Docker Volume for the ManifoldCF Maven Repository"
docker volume create --name mcf-maven-repo
echo "Creating Docker Volume for the ManifoldCF Installation..."
docker volume create --name mcf-app-volume
echo "Building the Docker Container for executing Ant and Maven build..."
docker build --build-arg MCF_VERSION=$mcfversionInFuction --build-arg MCF_DIST_URL=$mcfdistInFunction src/main/docker -t mcf-sdk-init
echo "Starting the mcf-sdk-build-container for executing the Maven and Ant building process..."
docker run -it --rm --name mcf-sdk-init-container -v mcf-maven-repo:/root/.m2 -v mcf-app-volume:/usr/src/manifoldcf -t mcf-sdk-init /bin/bash -c "sed -i -e 's/<fileset dir=\"test-materials\" excludes/<fileset dir=\"test-materials\" erroronmissingdir=\"false\" excludes/g' connectors/solr/build.xml; \
sed -i -e 's/<?xml version=\"1\.0\" encoding=\"UTF-8\"?>/ /g' connectors/csv/pom.xml; \
sed -i -e 's/https\:\/\/maven.nuxeo.org\/nexus\/content\/repositories\/public-releases/https\:\/\/packages.nuxeo.com\/repository\/maven-public-archives/g' build.xml; \
sed -i -e 's/https\:\/\/maven.nuxeo.org\/nexus\/content\/repositories\/public-releases\//https\:\/\/packages.nuxeo.com\/repository\/maven-public-archives/g' connectors/nuxeo/pom.xml; \
sed -i -e 's/<\/dependencies>/<dependency><groupId>org.apache.hadoop<\/groupId><artifactId>hadoop-annotations<\/artifactId><version>\${hadoop.version}<\/version><exclusions><exclusion><groupId>jdk.tools<\/groupId><artifactId>jdk.tools<\/artifactId><\/exclusion><\/exclusions><\/dependency><\/dependencies>/g' connectors/hdfs/pom.xml
ant make-core-deps make-deps build; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-api-service -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-api-service.war; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-authority-service -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-authority-service.war; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-combined-service -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-combined-service.war; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-crawler-ui -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-crawler-ui.war
mvn -B -e -T 1C clean install -DskipTests -DskipITs"
echo "Starting the mcf-sdk-init-container to export the Maven repository in target/mcf-maven-repo..."
docker run --rm --name mcf-sdk-init-container -itd -v mcf-maven-repo:/root/.m2 -v mcf-app-volume:/usr/src/manifoldcf -t mcf-sdk-init bash
echo "Copying the ManifoldCF Maven Repo in target/mcf-maven-repo..."
mkdir target
docker cp mcf-sdk-init-container:/root/.m2/repository target/mcf-maven-repo
echo "Stopping and removing the existent building container..."
docker stop mcf-sdk-init-container
#echo "Merging the ManifoldCF Maven Repository with the local Maven Repo"
#cp -n target/mcf-maven-repo $HOME/.m2
}
init() {
echo "Starting Apache ManifoldCF SDK initialization for version $mcfversion - Init"
mcfversionInFuction=$1
echo "Init - 1 - MCF version = $1"
mcfdistInFunction=$2
echo "Init - 2 - MCF DIST URL = $2"
mcfdistTypeInFunction=$3
echo "Init - 3 - MCF DIST TYPE = $3"
echo "Updating the ManifoldCF version inside the pom.xml"
mvn versions:set-property -Dproperty=manifoldcf.version -DnewVersion=$mcfversionInFuction
echo "Creating Docker Volume for the ManifoldCF Maven Repository"
docker volume create --name mcf-maven-repo
echo "Creating Docker Volume for the ManifoldCF Installation..."
docker volume create --name mcf-app-volume
echo "Building the Docker Container for executing Ant and Maven build..."
docker build --build-arg MCF_VERSION=$mcfversionInFuction --build-arg MCF_DIST_URL=$mcfdistInFunction src/main/docker -t mcf-sdk-init
echo "Starting the mcf-sdk-build-container for executing the Maven and Ant building process..."
docker run -it --rm --name mcf-sdk-init-container -v mcf-maven-repo:/root/.m2 -v mcf-app-volume:/usr/src/manifoldcf -t mcf-sdk-init /bin/bash -c "ant make-core-deps make-deps build; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-api-service -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-api-service.war; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-authority-service -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-authority-service.war; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-combined-service -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-combined-service.war; \
mvn install:install-file -DgroupId=org.apache.manifoldcf -DartifactId=mcf-crawler-ui -Dversion=$mcfversion -Dpackaging=war -Dfile=/usr/src/manifoldcf/dist/web/war/mcf-crawler-ui.war
mvn -B -e -T 1C clean install -DskipTests -DskipITs"
echo "Starting the mcf-sdk-init-container to export the Maven repository in target/mcf-maven-repo..."
docker run --rm --name mcf-sdk-init-container -itd -v mcf-maven-repo:/root/.m2 -v mcf-app-volume:/usr/src/manifoldcf -t mcf-sdk-init bash
echo "Copying the ManifoldCF Maven Repo in target/mcf-maven-repo..."
mkdir target
docker cp mcf-sdk-init-container:/root/.m2/repository target/mcf-maven-repo
echo "Stopping and removing the existent building container..."
docker stop mcf-sdk-init-container
#echo "Merging the ManifoldCF Maven Repository with the local Maven Repo"
#cp -n target/mcf-maven-repo $HOME/.m2
}
build_start() {
echo "Building with Maven skipping tests and run Docker containers"
mvn clean install docker:build docker:start -DskipTests -DskipITs
}
build_start_local() {
echo "Building with Maven skipping tests and run Docker containers"
mkdir target/mcf-dist
cp -R target/mcf-local/dist/. target/mcf-dist
mvn clean install docker:build docker:start -DskipTests -DskipITs -Plocal
}
build() {
echo "Building with Maven skipping tests"
mvn clean install -DskipTests -DskipITs
}
build_local() {
echo "Building with Maven skipping tests"
mvn clean install -DskipTests -DskipITs -Plocal
}
build_test() {
echo "Building with Maven executing tests"
mvn clean install
}
build_test_local() {
echo "Building with Maven executing tests"
mvn clean install -Plocal
}
unittests() {
echo "Executing unit tests"
mvn clean test
}
integrationtests() {
echo "Executing integration tests"
mvn clean integration-test
}
integrationtests_local() {
echo "Executing integration tests"
mvn clean integration-test -Plocal
}
start() {
echo "Run ManifoldCF Docker containers"
mvn docker:start
}
start_local() {
echo "Run ManifoldCF Docker containers"
mvn docker:start -Plocal
}
stop() {
echo "Stop ManifoldCF Docker containers"
mvn docker:stop
}
stop_local() {
echo "Stop ManifoldCF Docker containers"
mvn docker:stop -Plocal
}
test() {
echo "Starting the mcf-sdk-test-container to execute unit and integration tests"
docker run -it --rm -v mcf-maven-repo:/root/.m2 -v mcf-app-volume:/usr/src/manifoldcf -t mcf-sdk-init ant test
}
clean() {
echo "Starting the mcf-sdk-clean-container to clean the project"
docker run -it --rm -v mcf-maven-repo:/root/.m2 -v mcf-app-volume:/usr/src/manifoldcf -t mcf-sdk-init ant clean; mvn clean
}
purge() {
echo "Removing the ManifoldCF Maven repo and installation volumes"
docker volume rm mcf-maven-repo
docker volume rm mcf-app-volume
docker image rm mcf-sdk-init
}
case "$1" in
init)
if [ ! -n "$mcfversion" ] && [ "$mcfdist" != "local" ];
then
echo "$0 - Error ManifoldCF version is not set. Usage for using ManifoldCF 2.26: $0 init 2.26 ga or $0 init 2.27 rc"
exit 1
else
echo "ManifoldCF version is correctly set"
fi
if [ ! -n "$mcfdist" ];
then
echo "$0 - Error ManifoldCF release type is not set, it should be ga or rc. Usage for using ManifoldCF 2.21: $0 init 2.21 ga or $0 init 2.21 rc or $0 init local YOUR_LOCAL_PATH"
exit 1
else
echo "ManifoldCF release type is correctly set and now starting Apache ManifoldCF SDK initialization script..."
fi
if [ "$mcfdist" -eq "ga" ];
then
mcfdisturl="https://dlcdn.apache.org/manifoldcf"
echo "Building a GA release with artifact base URL: $mcfdisturl"
elif [ "$mcfdist" -eq "rc" ];
then
mcfdisturl="https://dist.apache.org/repos/dist/dev/manifoldcf"
echo "Building a RC release with artifact base URL: $mcfdisturl"
elif [ "$mcfdist" -eq "local" ];
then
echo "Building a local build: $mcfdisturl"
fi
if [ "$mcfdist"=="ga" ] && [ "$mcfversion" -eq "2.26" ];
then
echo "mcfversion=$mcfversion | mcfdisturl: $mcfdisturl | mcfdist: $mcfdist"
init226 $mcfversion $mcfdisturl $mcfdist
elif [ "$mcfdist"=="local" ];
then
echo "mcfversion=$mcfversion | mcfdisturl: $mcfdisturl | mcfdist: $mcfdist"
initLocal $mcfversion $mcfdisturl $mcfdist
else
echo "mcfversion=$mcfversion | mcfdisturl: $mcfdisturl | mcfdist: $mcfdist"
init $mcfversion $mcfdisturl $mcfdist
fi
;;
clean)
clean
;;
build_start)
build_start
;;
build_start_local)
build_start_local
;;
start)
start
;;
start_local)
start_local
;;
stop)
stop
;;
stop_local)
stop_local
;;
unittests)
unittests
;;
integrationtests)
integrationtests
;;
integrationtests_local)
integrationtests_local
;;
test)
test
;;
purge)
purge
;;
*)
echo "Usage: $0 {init|clean|build_start|build_start_local|start|start_local|stop|stop_local|unittests|integrationtests|integrationtests_local|test|purge}"
esac