11#! /bin/bash
22
3- SLUG=" atlanmod/Commons"
43JDK=" oraclejdk8"
54
65TYPE=" Javadoc"
7- TEMP_DIR=${HOME} /apidocs
86
97# Print a message
108e () {
@@ -25,9 +23,7 @@ skip() {
2523
2624# Check that the context is valid for publication
2725checkBuildInfo () {
28- if [ " $TRAVIS_REPO_SLUG " != " $SLUG " ]; then
29- skip " Wrong repository. Expected '$SLUG ' but was '$TRAVIS_REPO_SLUG '"
30- elif [ " $TRAVIS_JDK_VERSION " != " $JDK " ]; then
26+ if [ " $TRAVIS_JDK_VERSION " != " $JDK " ]; then
3127 skip " Wrong JDK. Expected '$JDK ' but was '$TRAVIS_JDK_VERSION '"
3228 elif [ " $TRAVIS_PULL_REQUEST " != " false" ]; then
3329 skip " Was pull request"
@@ -42,10 +38,10 @@ checkBuildInfo() {
4238generate () {
4339 e " Generating $TYPE ..."
4440
45- mvn -B -q javadoc:javadoc javadoc:aggregate -DreportOutputDirectory=" $HOME " -P " deploy-javadoc" & > /dev/null
41+ mvn -B -q javadoc:javadoc javadoc:aggregate -DreportOutputDirectory=" $( dirname $1 ) " -P " deploy-javadoc" & > /dev/null
4642
4743 # Check the generation
48- if ! [ -d " $TEMP_DIR " ]; then
44+ if ! [ -d " $1 " ]; then
4945 skip " No $TYPE has been generated"
5046 fi
5147}
@@ -65,16 +61,14 @@ cloneBranch() {
6561mergeIntoBranch () {
6662 e " Merging $TYPE ..."
6763
68- local outputDir=releases/snapshot/doc
69-
7064 # Remove existing artifacts
71- if [ -d " $outputDir " ]; then
72- git rm --quiet -rf " $outputDir /"
65+ if [ -d " $2 " ]; then
66+ git rm --quiet -rf " $2 /"
7367 fi
7468
7569 # Copy new artifacts
76- mkdir -p " $outputDir "
77- cp -Rfp " $TEMP_DIR /" * " $outputDir /"
70+ mkdir -p " $2 "
71+ cp -Rfp " $1 /" * " $2 /"
7872
7973 git add -Af
8074
@@ -97,19 +91,22 @@ publish() {
9791}
9892
9993main () {
94+ local tmpDir=${HOME} /apidocs
95+
10096 local branch=" gh-pages"
97+ local branchOutputDir=releases/snapshot/doc
10198
10299 # Working in the build directory
103100 checkBuildInfo
104- generate
101+ generate ${tmpDir}
105102
106103 # Working in the home directory
107104 cd " $HOME "
108105 cloneBranch ${branch}
109106
110107 # Working in branch directory
111108 cd " $branch "
112- mergeIntoBranch
109+ mergeIntoBranch ${tmpDir} ${branchOutputDir}
113110 publish ${branch}
114111}
115112
0 commit comments