Skip to content

Commit 49bba03

Browse files
author
John Jackson
committed
Restore build script broken in Wednesday's bad commit.
1 parent 46bfecb commit 49bba03

File tree

1 file changed

+68
-16
lines changed

1 file changed

+68
-16
lines changed

cdap-docs/developer-guide/build.sh

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# Copyright © 2014 Cask Data, Inc.
3+
# Copyright © 2014 Cask Data, Inc.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
66
# use this file except in compliance with the License. You may obtain a copy of
@@ -46,8 +46,8 @@ HTML_PATH="$BUILD_PATH/$HTML"
4646

4747
DOC_GEN_PY="$SCRIPT_PATH/../tools/doc-gen.py"
4848

49-
REST_SOURCE="$SOURCE_PATH/api.rst"
50-
REST_PDF="$SCRIPT_PATH/$BUILD_PDF/api.pdf"
49+
REST_SOURCE="$SOURCE_PATH/rest.rst"
50+
REST_PDF="$SCRIPT_PATH/$BUILD_PDF/rest.pdf"
5151

5252
if [ "x$2" == "x" ]; then
5353
PROJECT_PATH="$SCRIPT_PATH/../../"
@@ -60,6 +60,14 @@ SDK_JAVADOCS="$PROJECT_PATH/$API/target/site/$APIDOCS"
6060
ZIP_FILE_NAME=$HTML
6161
ZIP="$ZIP_FILE_NAME.zip"
6262

63+
# Set Google Analytics Codes
64+
# Corporate Docs Code
65+
GOOGLE_ANALYTICS_WEB="UA-55077523-3"
66+
WEB="web"
67+
# CDAP Project Code
68+
GOOGLE_ANALYTICS_GITHUB="UA-55081520-2"
69+
GITHUB="github"
70+
6371
function usage() {
6472
cd $PROJECT_PATH
6573
PROJECT_PATH=`pwd`
@@ -68,7 +76,8 @@ function usage() {
6876
echo ""
6977
echo " Options (select one)"
7078
echo " build Clean build of javadocs and HTML docs, copy javadocs and PDFs into place, zip results"
71-
echo " build-quick Quick build of docs using existing javadocs"
79+
echo " build-github Clean build and zip for placing on GitHub"
80+
echo " build-web Clean build and zip for placing on docs.cask.co webserver"
7281
echo ""
7382
echo " docs Clean build of docs"
7483
echo " javadocs Clean build of javadocs ($API module only) for SDK and website"
@@ -91,18 +100,25 @@ function clean() {
91100
}
92101

93102
function build_docs() {
103+
clean
94104
cd $SCRIPT_PATH
95105
sphinx-build -b html -d build/doctrees source build/html
96106
}
97107

108+
function build_docs_google() {
109+
clean
110+
cd $SCRIPT_PATH
111+
sphinx-build -D googleanalytics_id=$1 -D googleanalytics_enabled=1 -b html -d build/doctrees source build/html
112+
}
113+
98114
function build_javadocs_full() {
99115
cd $PROJECT_PATH
100116
mvn clean site -DskipTests
101117
}
102118

103119
function build_javadocs_sdk() {
104120
cd $PROJECT_PATH
105-
mvn clean package javadoc:javadoc -pl $API -am -DskipTests -P release
121+
MAVEN_OPTS="-Xmx512m" mvn clean package javadoc:javadoc -pl $API -am -DskipTests -P release
106122
}
107123

108124
function copy_javadocs_sdk() {
@@ -138,27 +154,61 @@ function copy_license_pdfs() {
138154
cp $SCRIPT_PATH/$LICENSES_PDF/* .
139155
}
140156

141-
function make_zip() {
157+
function make_zip_html() {
142158
version
143-
ZIP_FILE_NAME="$PROJECT-$HTML-docs-$PROJECT_VERSION.zip"
159+
ZIP_FILE_NAME="$PROJECT-docs-$PROJECT_VERSION.zip"
144160
cd $SCRIPT_PATH/$BUILD
145161
zip -r $ZIP_FILE_NAME $HTML/*
146162
}
147163

164+
function make_zip() {
165+
# This creates a zip that unpacks to the same name
166+
version
167+
ZIP_DIR_NAME="$PROJECT-docs-$PROJECT_VERSION-$1"
168+
cd $SCRIPT_PATH/$BUILD
169+
mv $HTML $ZIP_DIR_NAME
170+
zip -r $ZIP_DIR_NAME.zip $ZIP_DIR_NAME/*
171+
}
172+
173+
function make_zip_localized() {
174+
# This creates a named zip that unpacks to the Project Version, localized to english
175+
version
176+
ZIP_DIR_NAME="$PROJECT-docs-$PROJECT_VERSION-$1"
177+
cd $SCRIPT_PATH/$BUILD
178+
mkdir $PROJECT_VERSION
179+
mv $HTML $PROJECT_VERSION/en
180+
zip -r $ZIP_DIR_NAME.zip $PROJECT_VERSION/*
181+
}
182+
148183
function build() {
149-
clean
184+
build_docs
150185
build_javadocs_sdk
151186
copy_javadocs_sdk
152-
build_docs
153187
copy_license_pdfs
154188
make_zip
155189
}
156190

157-
function build_quick() {
158-
clean
159-
build_docs
191+
function build_web() {
192+
# This is used to stage files at cdap-integration10031-1000.dev.continuuity.net
193+
# desired path is 2.5.0-SNAPSHOT/en/*
194+
build_docs_google $GOOGLE_ANALYTICS_WEB
195+
build_javadocs_sdk
196+
copy_javadocs_sdk
160197
copy_license_pdfs
198+
make_zip_localized $WEB
199+
}
200+
201+
function build_github() {
202+
# GitHub requires a .nojekyll file at the root to allow for Sphinx's directories beginning with underscores
203+
build_docs_google $GOOGLE_ANALYTICS_GITHUB
204+
build_javadocs_sdk
161205
copy_javadocs_sdk
206+
copy_license_pdfs
207+
make_zip $GITHUB
208+
ZIP_DIR_NAME="$PROJECT-docs-$PROJECT_VERSION-$GITHUB"
209+
cd $SCRIPT_PATH/$BUILD
210+
touch $ZIP_DIR_NAME/.nojekyll
211+
zip $ZIP_DIR_NAME.zip $ZIP_DIR_NAME/.nojekyll
162212
}
163213

164214
function build_rest_pdf() {
@@ -171,10 +221,11 @@ function build_rest_pdf() {
171221

172222
function build_standalone() {
173223
cd $PROJECT_PATH
174-
MAVEN_OPTS="-Xmx512m" mvn clean package -DskipTests -P examples -pl cdap-examples -am -amd && mvn package -pl cdap-standalone -am -DskipTests -P dist,release
224+
MAVEN_OPTS="-Xmx512m" mvn clean package -DskipTests -P examples && mvn package -pl standalone -am -DskipTests -P dist,release
175225
}
176226

177227
function build_sdk() {
228+
build_rest_pdf
178229
build_standalone
179230
}
180231

@@ -219,11 +270,12 @@ fi
219270

220271
case "$1" in
221272
build ) build; exit 1;;
222-
build-quick ) build_quick; exit 1;;
273+
build-github ) build_github; exit 1;;
274+
build-web ) build_web; exit 1;;
223275
docs ) build_docs; exit 1;;
224276
license-pdfs ) build_license_pdfs; exit 1;;
225277
build-standalone ) build_standalone; exit 1;;
226-
copy-javadocs ) copy_javadocs_sdk; exit 1;;
278+
copy-javadocs ) copy_javadocs; exit 1;;
227279
copy-license-pdfs ) copy_license_pdfs; exit 1;;
228280
javadocs ) build_javadocs_sdk; exit 1;;
229281
javadocs-full ) build_javadocs_full; exit 1;;
@@ -234,4 +286,4 @@ case "$1" in
234286
test ) test; exit 1;;
235287
zip ) make_zip; exit 1;;
236288
* ) usage; exit 1;;
237-
esac
289+
esac

0 commit comments

Comments
 (0)