Repository navigation
Expand file tree
/
Copy pathgenerate-api-diff.sh
More file actions
executable file
·49 lines (42 loc) · 2.28 KB
/
Copy pathgenerate-api-diff.sh
File metadata and controls
executable file
·49 lines (42 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env 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 .utility folder of the 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.
./gradlew japicmp -PoldJarPath="${LATEST_RELEASE_JAR_PATH}" -PnewJarPath="${CURRENT_JAR_PATH}" -PoldJarVersion="${LATEST_RELEASE_VERSION}" -PnewJarVersion="${CURRENT_VERSION}"