This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_update_for_releases.sh
executable file
·735 lines (584 loc) · 20.5 KB
/
_update_for_releases.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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
#!/usr/bin/env bash
function usage() {
echo "Usage: ";
echo " ./update_for_releases.sh [command]";
echo " settings : configured settings";
# echo " clean : clean archive of unused versions";
echo " update : update released versions";
echo " nightly : update latest documentation from nightlies"
echo " canonize: update old version javadoc and documentation with jetty 12 metadata"
echo "";
echo "Artifacts are pulled from configured nexus, central, and lastly staging repositories."
}
function set_global_variables() {
MIN_JAVA_VERSION=17
VERSIONS_TXT=$(pwd)/_jettyVersions.txt
VERSIONS_PHP=$(pwd)/_jettyVersions.php
ARC_DIR=$(pwd)/_archive
JAVADOC_DIR=$(pwd)/javadoc
DOC_DIR=$(pwd)/documentation
TEMP_DIR=$ARC_DIR/temp
SCRIPT_DIR=$(pwd)
# use one of these and set on CLI, default to maven central?
#NEXUS_ROOT="http://10.0.0.15:8081/repository/maven-public"
NEXUS_ROOT="https://repo1.maven.org/maven2/org/eclipse/jetty"
MAVEN_ROOT="https://repo1.maven.org/maven2/org/eclipse/jetty"
STAGING_ROOT="https://oss.sonatype.org/content/groups/jetty-with-staging/org/eclipse/jetty"
GITHUB_ROOT="https://github.com/jetty/jetty.project/archive"
WEBSITE_ROOT="https://eclipse.dev/jetty"
DOC_ROOT_9="$MAVEN_ROOT/jetty-documentation"
DOC_ROOT_1x="$MAVEN_ROOT/documentation/jetty-documentation"
LOG_FILE="$ARC_DIR/update.log"
}
function print_global_variables() {
echo "Log File: $LOG_FILE"
echo "Versions File (txt): $VERSIONS_TXT"
echo "Versions File (php): $VERSIONS_PHP"
echo "Archive Directory: $ARC_DIR"
echo "Nexus Root URL: $NEXUS_ROOT"
echo "Maven Root URL: $MAVEN_ROOT"
echo "Maven Staging Root URL: $STAGING_ROOT"
echo "Documentation Root 9 URL: $DOC_ROOT_9"
echo "Documentation Root 1x URL: $DOC_ROOT_1x"
echo "Github Root URL: $GITHUB_ROOT"
}
function print_execution_variables() {
# TODO make dynamic
echo ""
echo "Version Variables"
echo "Jetty 9.2 = $jetty_9_2"
echo "Jetty 9.3 = $jetty_9_3"
echo "Jetty 9.4 = $jetty_9_4"
echo "Jetty 10.0 = $jetty_10_0"
echo "Jetty 11.0 = $jetty_11_0"
echo "Jetty 12.0 = $jetty_12_0"
echo "Jetty Nightly = $jetty_12_nightly"
echo "Jetty Nightly Resolved = $jetty_12_nightly_resolved"
echo ""
}
function init() {
echo ""
set_global_variables;
check_java_version;
reset_log;
create_archive_directory;
}
function check_java_version() {
if [[ -z "${JAVA_HOME}" ]]; then
echo "Error: JAVA_HOME environment variable not set, required for javadoc generation."
exit 1
fi
local java_version=$(java -version 2>&1 | head -n1 | sed -r 's/.*version "([0-9]*).*$/\1/');
if (( $java_version < $MIN_JAVA_VERSION)); then
echo "Error: java version must be $MIN_JAVA_VERSION+";
fi
}
function gather_current_versions() {
local version_file="_jettyVersions.txt"
# TODO make dynamic
# shellcheck disable=SC2162
while IFS= read line; do
if [[ $line == *"9.2."* ]]; then
jetty_9_2=$line;
fi
if [[ $line == *"9.3."* ]]; then
jetty_9_3=$line;
fi
if [[ $line == *"9.4."* ]]; then
jetty_9_4=$line;
fi
if [[ $line == *"10.0."* ]]; then
jetty_10_0=$line;
fi
if [[ $line == *"11.0."* ]]; then
jetty_11_0=$line;
fi
if [[ $line == *"12.0."* && $line != *"SNAPSHOT"* ]]; then
jetty_12_0=$line;
fi
if [[ $line == *"12.0."* && $line == *"SNAPSHOT"* ]]; then
jetty_12_nightly=$line;
fi
done <"$version_file"
}
function gather_nightly_version() {
local artifact="jetty-documentation";
local version="$1";
local filename="maven-metadata.xml";
maven_staging_download "documentation/$artifact" $version $filename;
local baseVersion=$(echo "$version" | tr -d '\-SNAPSHOT');
local timestamp=$(sed -n -e 's:.*<timestamp>\(.*\)</timestamp>.*:\1:p' "$ARC_DIR/$filename");
local build=$(sed -n -e 's:.*<buildNumber>\(.*\)</buildNumber>.*:\1:p' "$ARC_DIR/$filename");
#echo $baseVersion;
#echo $timestamp;
#echo $build;
jetty_12_nightly_resolved="$baseVersion-$timestamp-$build";
}
#
# set up archive directory if it doesn't exist
#
function create_archive_directory() {
if [ ! -d "$ARC_DIR" ]; then
mkdir "$ARC_DIR"
fi
}
function create_temp_directory() {
if [[ ! -d "$TEMP_DIR" ]]; then
mkdir "$TEMP_DIR"
fi
}
function delete_temp_directory() {
if [[ -d "$TEMP_DIR" ]]; then
rm -Rf "$TEMP_DIR";
fi
}
function reset_log() {
if [[ -e "$LOG_FILE" ]]; then
rm "$LOG_FILE";
fi
}
function get_primary_version() {
local version="$1";
IFS='.' read -ra ver <<<"$version"
echo "jetty-${ver[0]}";
}
function get_javadoc_version() {
local primary_version=$1
local javadoc_version
if [[ $primary_version == "jetty-9" ]]; then
javadoc_version=$(sed -e ':a' -e 'N;$!ba' -e 's/.*Project \([0-9.v]*\) API.*/\1/' "$JAVADOC_DIR/jetty-9/index.html")
elif [[ $primary_version == "jetty-10" ]]; then
javadoc_version=$(sed -e ':a' -e 'N;$!ba' -e 's/.*Doc - v\([0-9.]*\)).*/\1/' "$JAVADOC_DIR/jetty-10/index.html")
elif [[ $primary_version == "jetty-11" ]]; then
javadoc_version=$(sed -e ':a' -e 'N;$!ba' -e 's/.*Doc - v\([0-9.]*\)).*/\1/' "$JAVADOC_DIR/jetty-11/index.html")
elif [[ $primary_version == "jetty-12" ]]; then
javadoc_version=$(sed -e ':a' -e 'N;$!ba' -e 's/.*Doc - v\([0-9.]*\)).*/\1/' "$JAVADOC_DIR/jetty-12/index.html")
fi
echo "$javadoc_version"
}
function get_version_from_file_1x() {
local filename=$1
version=$("$filename")
echo "$version"
}
#
# we want to clear out files that are no longer required based on the current versions
#
function clean_archive_directory() {
# TODO implement correct behavior
if [ -d "$ARC_DIR" ]; then
rm -R "$ARC_DIR"
fi
}
function maven_download() {
local artifact=$1
local version=$2
local filename=$3
if [[ ! -f "$ARC_DIR/$filename" ]]; then
echo " - downloading from nexus $filename";
wget -O "$ARC_DIR/$filename" "$NEXUS_ROOT/$artifact/$version/$filename" &>>"$LOG_FILE";
local nexus_status=$?;
if [[ nexus_status -ne 0 ]]; then
echo " - downloading from maven $filename";
wget -O "$ARC_DIR/$filename" "$MAVEN_ROOT/$artifact/$version/$filename" &>>"$LOG_FILE";
local download_status=$?;
if [[ download_status -ne 0 ]]; then
maven_staging_download $1 $2 $3
fi
fi
fi
}
function maven_staging_download() {
local artifact=$1
local version=$2
local filename=$3
if [[ ! -f "$ARC_DIR/$filename" ]]; then
echo " - downloading from staging $filename";
wget -O "$ARC_DIR/$filename" "$STAGING_ROOT/$artifact/$version/$filename" &>>"$LOG_FILE";
local staging_status=$?;
if [[ staging_status -ne 0 ]]; then
echo " - download failed: $filename";
rm "$ARC_DIR/$filename" 2>/dev/null;
exit 1;
fi
fi
}
function github_download() {
local filename=$1
if [[ ! -f "$ARC_DIR/$filename" ]]; then
echo " - downloading $filename"
wget -O "$ARC_DIR/$filename" "$GITHUB_ROOT/$filename" &>>"$LOG_FILE";
local download_status=$?;
if [[ download_status -ne 0 ]]; then
echo " - download failed: $filename";
rm "$ARC_DIR/$filename";
exit 1
fi
fi
}
function download_distribution_files() {
local version=$1
if [[ "$version" == "1"* ]]; then
local artifact="jetty-home"
maven_download "$artifact" "$version" "$artifact-$version.zip";
else
local artifact="jetty-distribution"
fi
local filename_zasc="$artifact-$version.zip.asc";
local filename_zmd5="$artifact-$version.zip.md5";
local filename_zsha1="$artifact-$version.zip.sha1";
local filename_tasc="$artifact-$version.tar.gz.asc";
local filename_tmd5="$artifact-$version.tar.gz.md5";
local filename_tsha1="$artifact-$version.tar.gz.sha1";
maven_download "$artifact" "$version" "$filename_zasc";
maven_download "$artifact" "$version" "$filename_zmd5";
maven_download "$artifact" "$version" "$filename_zsha1";
maven_download "$artifact" "$version" "$filename_tasc";
maven_download "$artifact" "$version" "$filename_tmd5";
maven_download "$artifact" "$version" "$filename_tsha1";
}
function download_documentation_files() {
local artifact="jetty-documentation";
local version=$1;
local html_filename="$artifact-$version-html.zip";
local jar_filename="$artifact-$version-javadoc.jar";
local primary_version
primary_version=$(get_primary_version "$version")
echo "CHECK download doc files $artifact $version $html_filename"
if [[ $primary_version == "jetty-9" ]]; then
maven_download "$artifact" "$version" "$html_filename";
else
# this is a hack, should clean this up
maven_download "documentation/$artifact" "$version" "$html_filename";
maven_download "documentation/$artifact" "$version" "$jar_filename";
fi
}
function download_github_files() {
local version=$1
local filename="jetty-$version.zip"
github_download "$filename"
}
function download_missing_files() {
create_archive_directory
echo " - phase: downloads"
# TODO make dynamic
# Jetty 9.2
download_distribution_files "$jetty_9_2"
# Jetty 9.3
download_distribution_files "$jetty_9_3"
local versions=($jetty_9_4 $jetty_10_0 $jetty_11_0 $jetty_12_0)
for version in "${versions[@]}"; do
#echo "checking $jetty_12_0"
download_distribution_files "$version"
download_documentation_files "$version"
download_github_files "$version"
done
}
function download_nightly_documentation() {
local artifact="jetty-documentation";
local version=$jetty_12_nightly;
local filename="$artifact-$jetty_12_nightly_resolved-html.zip";
create_archive_directory;
echo " - phase: download nightly";
maven_staging_download "documentation/$artifact" $version $filename
}
function get_dist_info() {
if [[ "$1" == "1"* ]]; then
cat "$ARC_DIR/jetty-home-$1.$2"
else
cat "$ARC_DIR/jetty-distribution-$1.$2"
fi
}
function generate_version_php() {
# shellcheck disable=SC2206
# TODO make dynamic
local versions=($jetty_9_2 $jetty_9_3 $jetty_9_4 $jetty_10_0 $jetty_11_0 $jetty_12_0)
echo " - phase: version_php generation"
rm "$VERSIONS_PHP"
{
echo "<?php"
echo "/**"
echo "* Copyright (c) 2020 Eclipse Foundation."
echo "*"
echo "* This program and the accompanying materials are made"
echo "* available under the terms of the Eclipse Public License 2.0"
echo "* which is available at https://www.eclipse.org/legal/epl-2.0/"
echo "*"
echo "* Contributors:"
echo "* Jesse McConnell"
echo "*"
echo "* SPDX-License-Identifier: EPL-2.0"
echo "*/"
echo "\$jetty = array ("
for version in "${versions[@]}"; do
# shellcheck disable=SC2206
IFS='.' read -ra ver <<<"$version"
# shellcheck disable=SC2128
# shellcheck disable=SC2211
echo " 'jetty_${ver[0]}.${ver[1]}' => array ("
echo " 'version' => '$version',"
echo " 'zip.md5' => '$(get_dist_info "$version" "zip.md5")',"
echo " 'zip.sha1' => '$(get_dist_info "$version" "zip.sha1")',"
#echo " 'zip.asc' => '$(get_dist_info "$version" "zip.asc")',";
echo " 'tgz.md5' => '$(get_dist_info "$version" "tar.gz.md5")',"
echo " 'tgz.sha1' => '$(get_dist_info "$version" "tar.gz.sha1")',"
#echo " 'tgz.asc' => '$(get_dist_info "$version" "tgz.asc")',";
if [ "$version" == "${versions[-1]}" ]; then
echo " )"
else
echo " ),"
fi
done
echo ");"
} >>"$VERSIONS_PHP"
}
function process_documentation() {
# shellcheck disable=SC2206
local versions=($jetty_9_4 $jetty_10_0 $jetty_11_0 $jetty_12_0);
local directive=$1;
echo " - phase: documentation $directive"
create_temp_directory;
if [[ $directive == "nightly" ]]; then
local temp_ver_dir="$TEMP_DIR/$jetty_12_nightly_resolved";
unzip -d "$temp_ver_dir" "$ARC_DIR/jetty-documentation-$jetty_12_nightly_resolved-html.zip" &>>"$LOG_FILE";
{
local primary_version;
primary_version=$(get_primary_version "$jetty_12_0");
echo " - deploying $jetty_12_nightly documentation to $jetty_12_0"
find $temp_ver_dir -type f -name '*.html' -exec sed -i "s/$jetty_12_nightly/$jetty_12_0/gI" {} \;
rsync -avh "$TEMP_DIR/$jetty_12_nightly_resolved/$jetty_12_nightly/" "$DOC_DIR/$primary_version";
rm -Rf "$DOC_DIR/$primary_version/old_docs";
} &>>"$LOG_FILE";
else
for version in "${versions[@]}"; do
local temp_ver_dir="$TEMP_DIR/$version";
unzip -d "$temp_ver_dir" "$ARC_DIR/jetty-documentation-$version-html.zip" &>>"$LOG_FILE";
done
{
for version in "${versions[@]}"; do
local primary_version;
primary_version=$(get_primary_version "$version");
echo " - deploying documentation for $version"
rsync -avh "$TEMP_DIR/$version/$version/" "$DOC_DIR/$primary_version";
rm -Rf "$DOC_DIR/$primary_version/old_docs";
done;
} &>>"$LOG_FILE";
fi
delete_temp_directory;
}
function process_contribution_guide() {
local cleanVersions=($jetty_10_0 $jetty_11_0 $jetty_12_0)
local version=$jetty_12_0;
local directive=$1;
echo " - phase: position contribution guide $directive";
create_temp_directory;
{
if [[ $directive == "nightly" ]]; then
local temp_ver_dir="$TEMP_DIR/$jetty_12_nightly_resolved";
unzip -d "$temp_ver_dir" "$ARC_DIR/jetty-documentation-$jetty_12_nightly_resolved-html.zip";
find $temp_ver_dir -type f -name '*.html' -exec sed -i "s/$jetty_12_nightly/$jetty_12_0/gI" {} \;
rsync -avh "$TEMP_DIR/$jetty_12_nightly_resolved/$jetty_12_nightly/contribution-guide" "$DOC_DIR";
else
local temp_ver_dir="$TEMP_DIR/$version";
echo " - deploy latest contribution guide $version";
unzip -d "$temp_ver_dir" "$ARC_DIR/jetty-documentation-$version-html.zip";
rsync -avhc "$TEMP_DIR/$version/$version/contribution-guide" "$DOC_DIR";
fi
} &>>"$LOG_FILE";
# clean up old contribution guides
for cleanVersion in "${cleanVersions[@]}"; do
local cleanPrimaryVersion;
cleanPrimaryVersion=$(get_primary_version "$cleanVersion");
echo " - removing duplicate contribution guide in $cleanPrimaryVersion";
rm -Rf "$DOC_DIR/$cleanPrimaryVersion/contribution-guide";
done;
#delete_temp_directory;
}
function process_javadoc() {
# shellcheck disable=SC2206
# local versions=($jetty_9_4 $jetty_10_0 $jetty_11_0 $jetty_12_0)
local versions=($jetty_10_0 $jetty_11_0 $jetty_12_0)
local directive=$1;
echo " - phase: javadoc"
create_temp_directory
for version in "${versions[@]}"; do
local primary_version;
local javadoc_version;
local temp_build_dir="$TEMP_DIR/$version";
mkdir $temp_build_dir;
primary_version=$(get_primary_version "$version");
javadoc_version=$(get_javadoc_version "$primary_version");
if [[ $version == "$javadoc_version" ]]; then
echo " - skipping javadoc generation for $version";
else
build_javadoc "$primary_version" "$version" "$temp_build_dir"
deploy_javadoc "$primary_version" "$version" "$temp_build_dir"
fi
done;
delete_temp_directory
}
# TODO clean this up
function build_javadoc() {
local primary_version=$1
local version=$2
local temp_build_dir=$3
local filename="jetty-$version.zip"
echo " - building javadoc for $version"
{
if [[ $primary_version == "jetty-9" ]]; then
github_download "$filename";
unzip -d "$temp_build_dir" -o "$ARC_DIR/$filename"
cd "$temp_build_dir/jetty.project-jetty-$version" || exit 1
mvn clean install -DskipTests
mvn javadoc:aggregate
elif [[ $primary_version == "jetty-10" ]]; then
filename="jetty-documentation-$version-javadoc.jar"
cd $temp_build_dir || bail;
echo $temp_build_dir $pwd
jar -xf "$ARC_DIR/$filename"
elif [[ $primary_version == "jetty-11" ]]; then
filename="jetty-documentation-$version-javadoc.jar"
cd $temp_build_dir || exit 1;
jar -xf "$ARC_DIR/$filename"
elif [[ $primary_version == "jetty-12" ]]; then
filename="jetty-documentation-$version-javadoc.jar"
cd $temp_build_dir || exit 1;
jar -xf "$ARC_DIR/$filename"
fi
cd "$SCRIPT_DIR" || exit 1
} &>>"$LOG_FILE";
}
function bail() {
echo "Bailing out!";
exit 1;
}
#
#
function process_canonical() {
local old_versions=($jetty_9_4 $jetty_10_0 $jetty_11_0);
local canonical_version=$jetty_12_0;
local canonical_prime_version;
canonical_prime_version=$(get_primary_version "$canonical_version");
for old_version in "${old_versions[@]}"; do
local old_prime_version;
old_prime_version=$(get_primary_version "$old_version");
if [[ $old_prime_version == "jetty-9" ]]; then
#echo "implement $old_prime_version";
find_j9_doc_canonical_links $old_prime_version $canonical_prime_version $DOC_DIR "documentation";
find_canonical_links $old_prime_version $canonical_prime_version $JAVADOC_DIR "javadoc";
else
#echo " - make $old_prime_version files point to canonical $canonical_prime_version files";
find_canonical_links $old_prime_version $canonical_prime_version $DOC_DIR "documentation";
find_canonical_links $old_prime_version $canonical_prime_version $JAVADOC_DIR "javadoc";
fi;
done;
}
function find_j9_doc_canonical_links() {
local old_prime_version=$1;
local canonical_prime_version=$2;
local directory=$3;
local url_base=$4;
local old_files=($(find "$directory/$old_prime_version" -type f -name "*.html" -printf "%P\n"));
for file in "${old_files[@]}"; do
#echo " - check if canonical: $old_prime_version/$file";
if grep -q 'link rel="canonical" href' "$directory/$old_prime_version/$file"; then
#echo " - canonized $old_prime_version/$file";
local success=$(sed -i -e "s+<head>+<head><link rel=\"canonical\" href=\"$WEBSITE_ROOT/$url_base/$canonical_prime_version/index.html\"/>+gI" "$directory/$old_prime_version/$file" );
fi;
done;
}
function find_canonical_links() {
local old_prime_version=$1;
local canonical_prime_version=$2;
local directory=$3;
local url_base=$4;
local old_files=($(find "$directory/$old_prime_version" -type f -name "*.html" -printf "%P\n"));
for file in "${old_files[@]}"; do
#echo " - check if canonical: $old_prime_version/$file";
if grep -q 'link rel="canonical" href' "$directory/$old_prime_version/$file"; then
# echo " - canonized $old_prime_version/$file";
foo=bar;
elif [[ -f "$directory/$canonical_prime_version/$file" ]]; then
# echo " - canonizing $old_prime_version/$file";
local success=$(sed -i -e "s+<head>+<head><link rel=\"canonical\" href=\"$WEBSITE_ROOT/$url_base/$canonical_prime_version/$file\"/>+gI" "$directory/$old_prime_version/$file" );
# else
# echo " - canonical version doesn't exist $canonical_prime_version/$file";
fi;
done;
}
# true if the html file has a canonical header link
function is_not_canonicalized() {
local file=$1;
if grep -q 'link rel="canonical" href' $file; then
false;
else
true;
fi;
}
# TODO clean up
function deploy_javadoc() {
local primary_version=$1
local version=$2
local temp_build_dir=$3
local javadoc_src_dir
echo " - deploying javadoc for $version"
if [[ $primary_version == "jetty-9" ]]; then
javadoc_src_dir="$temp_build_dir/jetty.project-jetty-$version/target/site/apidocs/"
elif [[ $primary_version == "jetty-10" ]]; then
javadoc_src_dir="$temp_build_dir/"
elif [[ $primary_version == "jetty-11" ]]; then
javadoc_src_dir="$temp_build_dir/"
elif [[ $primary_version == "jetty-12" ]]; then
javadoc_src_dir="$temp_build_dir/"
fi
rsync -avh "$javadoc_src_dir" "$JAVADOC_DIR/$primary_version" &>>"$LOG_FILE";
}
#
# main
#
function main() {
directive=$1
# print out the settings this script operates under
if [[ $directive == "settings" ]]; then
init;
gather_current_versions;
print_global_variables;
print_execution_variables;
#echo "test" &>>"$LOG_FILE";
exit 0;
fi
# run an update process for any version changes
if [[ $directive == "update" ]]; then
init;
gather_current_versions;
download_missing_files;
generate_version_php;
#process_documentation;
process_contribution_guide;
#process_javadoc;
#process_canonical;
exit 0;
fi
# run an update process for any nightly doc changes
if [[ $directive == "nightly" ]]; then
init;
gather_current_versions;
gather_nightly_version $jetty_12_nightly;
#print_execution_variables;
download_nightly_documentation;
process_documentation $directive;
process_contribution_guide $directive;
process_canonical;
exit 0;
fi
if [[ $directive == "canonize" ]]; then
init;
gather_current_versions;
process_canonical;
exit 0;
fi
# print usage
usage;
exit 0;
}
main "$1"