Skip to content

Commit 5422e85

Browse files
author
Yoann Vernageau
committed
generalize build scripts
1 parent 5fe93dd commit 5422e85

2 files changed

Lines changed: 13 additions & 19 deletions

File tree

.util/deploy_snapshot.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22

3-
SLUG="atlanmod/Commons"
43
JDK="oraclejdk8"
54

65
TYPE="Maven snapshot"
@@ -24,9 +23,7 @@ skip() {
2423

2524
# Check that the context is valid for deployment
2625
checkBuildInfo() {
27-
if [ "$TRAVIS_REPO_SLUG" != "$SLUG" ]; then
28-
skip "Wrong repository. Expected '$SLUG' but was '$TRAVIS_REPO_SLUG'"
29-
elif [ "$TRAVIS_JDK_VERSION" != "$JDK" ]; then
26+
if [ "$TRAVIS_JDK_VERSION" != "$JDK" ]; then
3027
skip "Wrong JDK. Expected '$JDK' but was '$TRAVIS_JDK_VERSION'"
3128
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
3229
skip "Was pull request"

.util/publish_javadoc.sh

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#!/bin/bash
22

3-
SLUG="atlanmod/Commons"
43
JDK="oraclejdk8"
54

65
TYPE="Javadoc"
7-
TEMP_DIR=${HOME}/apidocs
86

97
# Print a message
108
e() {
@@ -25,9 +23,7 @@ skip() {
2523

2624
# Check that the context is valid for publication
2725
checkBuildInfo() {
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() {
4238
generate() {
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() {
6561
mergeIntoBranch() {
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

9993
main() {
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

Comments
 (0)