summaryrefslogtreecommitdiff
path: root/platform/android/gradle/android-nitpick.gradle
diff options
context:
space:
mode:
authorŁukasz Paczos <lukas.paczos@gmail.com>2019-01-28 13:10:06 +0100
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2019-01-29 15:21:01 +0100
commite598146399a9d53a2d78b3b45eb1a69ca367dcf3 (patch)
treec1e142ea9611cebe8bc8e12fe02871ceb24493c9 /platform/android/gradle/android-nitpick.gradle
parentca8625fba1bc86a42323236f27cb2c7f803a11c5 (diff)
downloadqtlocation-mapboxgl-e598146399a9d53a2d78b3b45eb1a69ca367dcf3.tar.gz
[android] android nitpick script, verify submodule pins
Diffstat (limited to 'platform/android/gradle/android-nitpick.gradle')
-rw-r--r--platform/android/gradle/android-nitpick.gradle53
1 files changed, 53 insertions, 0 deletions
diff --git a/platform/android/gradle/android-nitpick.gradle b/platform/android/gradle/android-nitpick.gradle
new file mode 100644
index 0000000000..dfcbcfb869
--- /dev/null
+++ b/platform/android/gradle/android-nitpick.gradle
@@ -0,0 +1,53 @@
+apply from: "${rootDir}/gradle/dependencies.gradle"
+
+def MAPBOX_JAVA_DIR = 'mapbox-java'
+def MAPBOX_JAVA_TAG_PREFIX = 'v'
+
+def MAPBOX_TELEMETRY_DIR = 'mapbox-events-android'
+def MAPBOX_TELEMETRY_TAG_PREFIX = 'telem-'
+
+def MAPBOX_GESTURES_DIR = 'mapbox-gestures-android'
+def MAPBOX_GESTURES_TAG_PREFIX = 'v'
+
+task verifyVendorSubmodulePins {
+ doLast {
+ println "Verify vendor submodule pins"
+ verifyVendorSubmodulePin(MAPBOX_JAVA_DIR, MAPBOX_JAVA_TAG_PREFIX, versions.mapboxServices)
+ verifyVendorSubmodulePin(MAPBOX_TELEMETRY_DIR, MAPBOX_TELEMETRY_TAG_PREFIX, versions.mapboxTelemetry)
+ verifyVendorSubmodulePin(MAPBOX_GESTURES_DIR, MAPBOX_GESTURES_TAG_PREFIX, versions.mapboxGestures)
+ }
+}
+
+task androidNitpick {
+ doLast {
+ println "Running android nitpick script"
+ verifyVendorSubmodulePins
+ }
+}
+
+private def verifyVendorSubmodulePin(def dir, def prefix, def version) {
+ def output = new ByteArrayOutputStream()
+ exec {
+ workingDir "${rootDir}/vendor/${dir}"
+ commandLine "git", "rev-list", "-n", "1", "tags/${prefix + version}"
+ standardOutput = output
+ }
+ def expectedCommit = output.toString().trim()
+ output.reset()
+
+ exec {
+ workingDir "${rootDir}/vendor/${dir}"
+ commandLine "git", "rev-parse", "HEAD"
+ standardOutput = output
+ }
+ def actualCommit = output.toString().trim()
+
+ if (actualCommit != expectedCommit) {
+ throw new IllegalStateException("${dir} vendor repository is not checked out on the consumed binary's tag.\n" +
+ "Expected commit: " + expectedCommit + "(${prefix + version} tag).\n" +
+ "Actual commit: " + actualCommit + ".\n" +
+ "If you've updated the version in the dependencies.gradle file, make sure to bump the submodule pin in the platform/android/vendor/ directory to match the release tag.\n" +
+ "If you've bumped the pin, make sure to verify the version tag prefix in the android-nitpick.gradle file.")
+ }
+ output.close()
+} \ No newline at end of file