Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .utility/generate-api-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# Author: Hanbin Cho (mraerok@gmail.com)
# Description: This script 1) downloads the latest java-sdk jar published in Maven Repo 2) builds the jar of current java-sdk version, then 3) generate an API diff report of the two versions.
# Assumptions
# 1. This script is placed in the project root of java-sdk.
# 2. Version format is [0-9].[0-9].[0-9]

# Step 1: Download the latest release of java-sdk published in Maven Repository.
mvn dependency:get \
-DgroupId=com.ibm.watson.developer_cloud \
-DartifactId=java-sdk \
-Dversion=LATEST \
-Dpackaging=jar \
-Dclassifier=jar-with-dependencies \
-Dtransitive=false

# Step 2: Construct the filepath to the latest release of java-sdk.
LOCAL_MAVEN_REPO_PATH="${HOME}/.m2/repository"
RELEASE_JAR_BASEPATH="${LOCAL_MAVEN_REPO_PATH}/com/ibm/watson/developer_cloud/java-sdk"
pushd $RELEASE_JAR_BASEPATH
LATEST_RELEASE_VERSION=`ls | grep -d read "[0-9]\.[0-9]\.[0-9]" | sort | tail -n 1`
LATEST_RELEASE_JAR_FILENAME="java-sdk-${LATEST_RELEASE_VERSION}-jar-with-dependencies.jar"
LATEST_RELEASE_JAR_PATH="${RELEASE_JAR_BASEPATH}/${LATEST_RELEASE_VERSION}/${LATEST_RELEASE_JAR_FILENAME}"

# Step 3: Validate the filepath to the latest release of java-sdk.
if [ ! -f $LATEST_RELEASE_JAR_PATH ]; then
echo "apidiff.sh: Latest release jar was not at its expected location at: $LATEST_RELEASE_JAR_PATH"
popd
exit 1
fi
popd

# Step 4: Generate a stand-alone jar of the current version of java-sdk.
./gradlew shadowJar

# Step 5: Construct the filepath to the current version of java-sdk.
CURRENT_VERSION=`cat gradle.properties | grep "version=[0-9]\.[0-9]\.[0-9]" | cut -d '=' -f 2`
CURRENT_JAR_FILENAME="java-sdk-${CURRENT_VERSION}-jar-with-dependencies.jar"
CURRENT_JAR_BASEPATH="java-sdk/build/libs"
CURRENT_JAR_PATH="${CURRENT_JAR_BASEPATH}/${CURRENT_JAR_FILENAME}"

# Step 6: Validate the filepath to the current version of java-sdk.
if [ ! -f $CURRENT_JAR_PATH ]; then
echo "apidiff.sh: Current jar was not at its expected location at: $CURRENT_JAR_PATH"
exit 1
fi

# Step 7: Produce an API diff between the latest release and the current version using japicmp module.
# TODO: Figure out how to set japicmp task's properties (oldClasspath and newClasspath) through command-line invocation.
./gradlew japicmp -PoldJarPath="${LATEST_RELEASE_JAR_PATH}" -PnewJarPath="${CURRENT_JAR_PATH}" -PoldJarVersion="${LATEST_RELEASE_VERSION}" -PnewJarVersion="${CURRENT_VERSION}"
39 changes: 39 additions & 0 deletions .utility/generate_apidiff_index_html.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

# based on https://odoepner.wordpress.com/2012/02/17/shell-script-to-generate-simple-index-html/

echo '<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>IBM Watson Developer Cloud</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>IBM Watson Developer Cloud Java SDK API Diff</h1>
</div>
<p><a href="https://www.ibm.com/watson/developer/">Info</a>
| <a href="https://console.bluemix.net/developer/watson/documentation">Documentation</a>
| API Diff
| <a href="https://github.com/watson-developer-cloud/java-sdk">GitHub</a>
| <a href="http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.ibm.watson.developer_cloud%22%20a%3A%22java-sdk%22">Maven</a>
</p>
<p>API Diff by version</p>
<ul>'
ls apidiff/ | grep --invert-match index.html | sed 's/^.*/<li><a href="&">&<\/a><\/li>/'
echo ' </ul>
</div>
<script>
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
ga("create", "UA-59827755-4", "auto");
ga("send", "pageview");
</script>
</body>
</html>'
1 change: 1 addition & 0 deletions .utility/generate_index_html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ echo '<!DOCTYPE html>
<p><a href="https://www.ibm.com/watson/developer/">Info</a>
| <a href="https://console.bluemix.net/developer/watson/documentation">Documentation</a>
| <a href="http://watson-developer-cloud.github.io/java-sdk/apidiff">API Diff</a>
| <a href="https://github.com/watson-developer-cloud/java-sdk">GitHub</a>
| <a href="http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.ibm.watson.developer_cloud%22%20a%3A%22java-sdk%22">Maven</a>
</p>
Expand Down
10 changes: 8 additions & 2 deletions .utility/push-javadoc-to-gh-pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then
# on tagged builds, $TRAVIS_BRANCH is the tag (e.g. v1.2.3), otherwise it's the branch name (e.g. master)
rm -rf docs/$TRAVIS_BRANCH
mkdir -p docs/$TRAVIS_BRANCH

cp -rf ../build/docs/all/* docs/$TRAVIS_BRANCH
../.utility/generate_index_html.sh > index.html

# update the latest/ symlink
# produce API diff of the current version and the latest release
../.utility/generate-api-diff.sh
rm -rf apidiff/
mkdir apidiff/
cp -f ../build/reports/java-sdk-api-diff* apidiff/
../.utility/generate_apidiff_index_html.sh > apidiff/index.html

# update the latest/ symlink
# on tagged builds, $TRAVIS_TAG is set to the tag, but it's blank on regular builds, unlike $TRAVIS_BRANCH
if [ $TRAVIS_TAG ]; then
rm latest
Expand Down
28 changes: 28 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'net.researchgate.release' version '2.4.0'
id 'me.champeau.gradle.japicmp' version '0.2.6'
}

apply from: 'utils.gradle'
Expand Down Expand Up @@ -138,5 +139,32 @@ task printversion {
}
}

task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask) {
ext.oldJarVersion =
project.hasProperty('oldJarVersion')
? project.getProperty('oldJarVersion')
: "pass-in-older-jar-version"
ext.newJarVersion =
project.hasProperty('newJarVersion')
? project.getProperty('newJarVersion')
: "pass-in-newer-jar-version"
ext.oldJarPath =
project.hasProperty('oldJarPath')
? project.getProperty('oldJarPath')
: "pass/in/path/to/older/version.jar"
ext.newJarPath =
project.hasProperty('newJarPath')
? project.getProperty('newJarPath')
: "pass/in/path/to/newer/version.jar"

oldClasspath = files(oldJarPath)
newClasspath = files(newJarPath)

onlyModified = true
failOnModification = true

htmlOutputFile = file("$buildDir/reports/java-sdk-api-diff-" + oldJarVersion + "-to-" + newJarVersion + ".html")
}

beforeReleaseBuild.dependsOn startmessage
afterReleaseBuild.dependsOn printversion