Skip to content

Commit

Permalink
Restore build script broken in Wednesday's bad commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Jackson committed Sep 26, 2014
1 parent 46bfecb commit 49bba03
Showing 1 changed file with 68 additions and 16 deletions.
84 changes: 68 additions & 16 deletions cdap-docs/developer-guide/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Copyright © 2014 Cask Data, Inc.
# Copyright © 2014 Cask Data, Inc.
#
# Licensed 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
Expand Down Expand Up @@ -46,8 +46,8 @@ HTML_PATH="$BUILD_PATH/$HTML"

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

REST_SOURCE="$SOURCE_PATH/api.rst"
REST_PDF="$SCRIPT_PATH/$BUILD_PDF/api.pdf"
REST_SOURCE="$SOURCE_PATH/rest.rst"
REST_PDF="$SCRIPT_PATH/$BUILD_PDF/rest.pdf"

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

# Set Google Analytics Codes
# Corporate Docs Code
GOOGLE_ANALYTICS_WEB="UA-55077523-3"
WEB="web"
# CDAP Project Code
GOOGLE_ANALYTICS_GITHUB="UA-55081520-2"
GITHUB="github"

function usage() {
cd $PROJECT_PATH
PROJECT_PATH=`pwd`
Expand All @@ -68,7 +76,8 @@ function usage() {
echo ""
echo " Options (select one)"
echo " build Clean build of javadocs and HTML docs, copy javadocs and PDFs into place, zip results"
echo " build-quick Quick build of docs using existing javadocs"
echo " build-github Clean build and zip for placing on GitHub"
echo " build-web Clean build and zip for placing on docs.cask.co webserver"
echo ""
echo " docs Clean build of docs"
echo " javadocs Clean build of javadocs ($API module only) for SDK and website"
Expand All @@ -91,18 +100,25 @@ function clean() {
}

function build_docs() {
clean
cd $SCRIPT_PATH
sphinx-build -b html -d build/doctrees source build/html
}

function build_docs_google() {
clean
cd $SCRIPT_PATH
sphinx-build -D googleanalytics_id=$1 -D googleanalytics_enabled=1 -b html -d build/doctrees source build/html
}

function build_javadocs_full() {
cd $PROJECT_PATH
mvn clean site -DskipTests
}

function build_javadocs_sdk() {
cd $PROJECT_PATH
mvn clean package javadoc:javadoc -pl $API -am -DskipTests -P release
MAVEN_OPTS="-Xmx512m" mvn clean package javadoc:javadoc -pl $API -am -DskipTests -P release
}

function copy_javadocs_sdk() {
Expand Down Expand Up @@ -138,27 +154,61 @@ function copy_license_pdfs() {
cp $SCRIPT_PATH/$LICENSES_PDF/* .
}

function make_zip() {
function make_zip_html() {
version
ZIP_FILE_NAME="$PROJECT-$HTML-docs-$PROJECT_VERSION.zip"
ZIP_FILE_NAME="$PROJECT-docs-$PROJECT_VERSION.zip"
cd $SCRIPT_PATH/$BUILD
zip -r $ZIP_FILE_NAME $HTML/*
}

function make_zip() {
# This creates a zip that unpacks to the same name
version
ZIP_DIR_NAME="$PROJECT-docs-$PROJECT_VERSION-$1"
cd $SCRIPT_PATH/$BUILD
mv $HTML $ZIP_DIR_NAME
zip -r $ZIP_DIR_NAME.zip $ZIP_DIR_NAME/*
}

function make_zip_localized() {
# This creates a named zip that unpacks to the Project Version, localized to english
version
ZIP_DIR_NAME="$PROJECT-docs-$PROJECT_VERSION-$1"
cd $SCRIPT_PATH/$BUILD
mkdir $PROJECT_VERSION
mv $HTML $PROJECT_VERSION/en
zip -r $ZIP_DIR_NAME.zip $PROJECT_VERSION/*
}

function build() {
clean
build_docs
build_javadocs_sdk
copy_javadocs_sdk
build_docs
copy_license_pdfs
make_zip
}

function build_quick() {
clean
build_docs
function build_web() {
# This is used to stage files at cdap-integration10031-1000.dev.continuuity.net
# desired path is 2.5.0-SNAPSHOT/en/*
build_docs_google $GOOGLE_ANALYTICS_WEB
build_javadocs_sdk
copy_javadocs_sdk
copy_license_pdfs
make_zip_localized $WEB
}

function build_github() {
# GitHub requires a .nojekyll file at the root to allow for Sphinx's directories beginning with underscores
build_docs_google $GOOGLE_ANALYTICS_GITHUB
build_javadocs_sdk
copy_javadocs_sdk
copy_license_pdfs
make_zip $GITHUB
ZIP_DIR_NAME="$PROJECT-docs-$PROJECT_VERSION-$GITHUB"
cd $SCRIPT_PATH/$BUILD
touch $ZIP_DIR_NAME/.nojekyll
zip $ZIP_DIR_NAME.zip $ZIP_DIR_NAME/.nojekyll
}

function build_rest_pdf() {
Expand All @@ -171,10 +221,11 @@ function build_rest_pdf() {

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

function build_sdk() {
build_rest_pdf
build_standalone
}

Expand Down Expand Up @@ -219,11 +270,12 @@ fi

case "$1" in
build ) build; exit 1;;
build-quick ) build_quick; exit 1;;
build-github ) build_github; exit 1;;
build-web ) build_web; exit 1;;
docs ) build_docs; exit 1;;
license-pdfs ) build_license_pdfs; exit 1;;
build-standalone ) build_standalone; exit 1;;
copy-javadocs ) copy_javadocs_sdk; exit 1;;
copy-javadocs ) copy_javadocs; exit 1;;
copy-license-pdfs ) copy_license_pdfs; exit 1;;
javadocs ) build_javadocs_sdk; exit 1;;
javadocs-full ) build_javadocs_full; exit 1;;
Expand All @@ -234,4 +286,4 @@ case "$1" in
test ) test; exit 1;;
zip ) make_zip; exit 1;;
* ) usage; exit 1;;
esac
esac

0 comments on commit 49bba03

Please sign in to comment.