-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild-asciidocs.sh
executable file
·117 lines (102 loc) · 3.73 KB
/
build-asciidocs.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
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
# This shell script can be used to fast add or update cayenne Asciidoc documentation.
# For safety reason changes should be committed manually.
#
# Usage:
# > build-asciidocs.sh git-tag cayenne-version
#
# Options:
# git-tag: tag that will be used to build documentation
# cayenne-version: optional parameter, cayenne version for which docs are build.
# If not set git-tag will be used as version.
#
# Example:
# Build docs for release 4.1.M1:
# > build-asciidocs.sh 4.1
#
# Build docs for old 3.1.1 release:
# > build-asciidocs.sh cayenne-parent-3.1.1 3.1
#
# Build docs for master:
# > build-asciidocs.sh master 4.1
#
function checkAndCreateDir() {
if [ ! -d "$1" ]; then
echo "Creating doc dir: $1"
mkdir "$1"
fi
}
function clearDir() {
if [ -d "$1" ]; then
echo "Clearing dir: $1"
rm -rf "$1/"
fi
}
# no input, so just exit
if [ -z "$1" ]; then
echo "Usage: build-asciidocs.sh git-tag [cayenne-version]"
exit -1
fi
GIT_TAG="$1"
VERSION="$GIT_TAG"
# version can be passed as a second parameter
if [ -z "$2" ]; then
echo "Using git-tag \"$GIT_TAG\" as cayenne version"
else
VERSION="$2"
echo "Using git-tag \"$GIT_TAG\" and cayenne version $VERSION"
fi
# change dir to one with this script
cd "$( dirname "${BASH_SOURCE[0]}" )"
BASE_DIR=`pwd` # base project dir
echo "Working dir: $BASE_DIR"
# init and check paths
MAJOR_VERSION="${VERSION:0:3}" # expecting version format as X.Y.something-else, i.e. 4.1.M1 is ok, but 4.12.M1 will fail..
ASCII_DOC_DIR="$BASE_DIR/src/main/site/content/docs/$MAJOR_VERSION" # Asciidoc goes to content, Hugo will process it
CAYENNE_TMP_DIR="$BASE_DIR/target/cayenne-tmp" # tmp directory to checkout Cayenne
# prepare all directories
clearDir "$CAYENNE_TMP_DIR"
checkAndCreateDir "$ASCII_DOC_DIR"
echo "Building docs for Cayenne $MAJOR_VERSION ($VERSION)"
# clone git repo and checkout requested TAG
git clone https://github.com/apache/cayenne.git "$CAYENNE_TMP_DIR" --branch "$GIT_TAG" --depth 1
# we will need Maven to build only asciidoc modules
cd "$CAYENNE_TMP_DIR"
# build it
echo "Running Maven build... it can take a while..."
mvn package -Passembly -q -DskipTests -Dcayenne.version=${VERSION} -pl !modeler,!modeler/cayenne-modeler,\
!modeler/cayenne-modeler-generic,!modeler/cayenne-modeler-generic-ext,\
!modeler/cayenne-modeler-mac,!modeler/cayenne-modeler-mac-ext,\
!modeler/cayenne-modeler-win,!modeler/cayenne-modeler-win-ext,\
!modeler/cayenne-wocompat,!assembly,!cayenne-gradle-plugin,!docs/doc\
> /dev/null 2>&1
echo "Maven build complete"
cd "docs/asciidoc/"
# copy everything from ./docs/asciidoc/**/target/site/** directories
for d in */ ; do
# skip asciidoc extension module
if [ "$d" == "cayenne-asciidoc-extension/" ]; then
continue
fi
echo "Syncing asciidoc content for ${d}"
cp -R "./${d}target/site/." "$ASCII_DOC_DIR/"
done