Skip to content

Commit c5d9af2

Browse files
committed
chore(build): add build scripts
1 parent 8e821f7 commit c5d9af2

File tree

7 files changed

+137
-0
lines changed

7 files changed

+137
-0
lines changed

build/.travis.settings.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
4+
<servers>
5+
<server>
6+
<id>ossrh</id>
7+
<username>${env.OSSRH_USERNAME}</username>
8+
<password>${env.OSSRH_PASSWORD}</password>
9+
</server>
10+
</servers>
11+
</settings>

build/generateJavadocIndex.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# based on https://odoepner.wordpress.com/2012/02/17/shell-script-to-generate-simple-index-html/
4+
5+
echo '<!DOCTYPE html>
6+
<html>
7+
<head>
8+
<meta charset="utf-8">
9+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
10+
<meta name="viewport" content="width=device-width, initial-scale=1">
11+
<title>IBM Watson Java SDK </title>
12+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" crossorigin="anonymous">
13+
</head>
14+
<body>
15+
<div class="container">
16+
<div class="page-header">
17+
<h1>Java client library to use the IBM Watson APIs</h1>
18+
</div>
19+
20+
<p><a href="https://cloud.ibm.com/apidocs?category=<service-category>">My Services Info</a>
21+
| <a href="https://github.com/watson-developer-cloud/java-sdk">GitHub</a>
22+
</p>
23+
24+
<p>Javadoc by branch/release:</p>
25+
<ul><li><a href="docs/latest">Latest</a></li>'
26+
ls docs | grep --invert-match index.html | sed 's/^.*/<li><a href="docs\/&">&<\/a><\/li>/'
27+
echo ' </ul>
28+
</div>
29+
</body>
30+
</html>'

build/publishCodeCoverage.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# This script will publish code coverage info for a build of the main branch
4+
# or a tagged release.
5+
6+
if [[ -n "${TRAVIS_TAG}" || "${TRAVIS_BRANCH}" == "main" && "${TRAVIS_PULL_REQUEST}" == "false" ]]; then
7+
printf ">>>>> Publishing code coverage info for branch: %s\n" ${TRAVIS_BRANCH}
8+
$HOME/codecov-bash.sh -s modules/coverage-reports/target/site/jacoco-aggregate -t $CODECOV_TOKEN
9+
else
10+
printf ">>>>> Bypassing code coverage publish step for feature branch/PR build.\n"
11+
fi
12+

build/publishJavadoc.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
# This script will publish the aggregated javadocs found in the project's "target" directory.
4+
# The javadocs are committed and pushed to the git repository's gh-pages branch.
5+
# Be sure to customize this file to reflect your SDK project's settings (git url,
6+
7+
# Avoid publishing javadocs for a PR build
8+
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then
9+
10+
printf "\n>>>>> Publishing javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER}
11+
12+
printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n"
13+
rm -fr ./gh-pages
14+
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/watson-developer-cloud/java-sdk.git gh-pages > /dev/null
15+
16+
printf "\n>>>>> Finished cloning...\n"
17+
18+
19+
pushd gh-pages
20+
21+
# Create a new directory for this branch/tag and copy the aggregated javadocs there.
22+
printf "\n>>>>> Copying aggregated javadocs to new tagged-release directory: %s\n" ${TRAVIS_BRANCH}
23+
rm -rf docs/${TRAVIS_BRANCH}
24+
mkdir -p docs/${TRAVIS_BRANCH}
25+
cp -rf ../target/site/apidocs/* docs/${TRAVIS_BRANCH}
26+
27+
printf "\n>>>>> Generating gh-pages index.html...\n"
28+
../build/generateJavadocIndex.sh > index.html
29+
30+
# Update the 'latest' symlink to point to this branch if it's a tagged release.
31+
if [ -n "$TRAVIS_TAG" ]; then
32+
pushd docs
33+
rm latest
34+
ln -s ./${TRAVIS_TAG} latest
35+
printf "\n>>>>> Updated 'docs/latest' symlink:\n"
36+
ls -l latest
37+
popd
38+
fi
39+
40+
printf "\n>>>>> Committing new javadoc...\n"
41+
git add -f .
42+
git commit -m "Javadoc for release ${TRAVIS_TAG} (${TRAVIS_COMMIT})"
43+
git push -f origin gh-pages
44+
45+
popd
46+
47+
printf "\n>>>>> Published javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER}
48+
49+
else
50+
51+
printf "\n>>>>> Javadoc publishing bypassed for non-release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER}
52+
53+
fi

build/setMavenVersion.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# This script will check $TRAVIS_TAG to see if we need to run maven to
4+
# set the artifact version #'s.
5+
6+
if [[ -n "${TRAVIS_TAG}" ]]; then
7+
printf "\n>>>>> Setting artifact version #'s to: %s\n" ${TRAVIS_TAG:1}
8+
mvn versions:set -DnewVersion=${TRAVIS_TAG:1} -DgenerateBackupPoms=false
9+
else
10+
printf "\n>>>>> Bypassing artifact version setting for non-tagged build\n"
11+
fi
12+

build/setupSigning.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -x
3+
4+
# This script is responsible for decrypting your encrypted signing key file
5+
# (build/signing.key.enc), and importing it into the gpg keystore.
6+
# This is done so that your maven build will be able to properly sign your jars
7+
# prior to publishing them on maven central.
8+
9+
echo "Importing signing key..."
10+
11+
# Modify the command below to use the correct environment variables
12+
# that were added to your Travis build settings when you encrypted your signing.key file.
13+
openssl aes-256-cbc -K $encrypted_6afd0fc9428e_key -iv $encrypted_6afd0fc9428e_iv -in build/signing.key.enc -out build/signing.key -d
14+
15+
gpg --version
16+
gpg --fast-import build/signing.key
17+
rm build/signing.key
18+
19+
echo "Signing key import finished!"
File renamed without changes.

0 commit comments

Comments
 (0)