From 8a1cf7ff5c39ccd5e6edfda4d06939c7126e2936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Mon, 28 Jan 2019 11:42:18 +0100 Subject: [PATCH 1/4] [android] revert modules vendorization and keep submodules only (cherry picked from commit ca8625fba1bc86a42323236f27cb2c7f803a11c5) --- Makefile | 12 +---- platform/android/LICENSE.md | 48 +++++++++++++++++++ .../android/MapboxGLAndroidSDK/build.gradle | 12 +++-- .../MapboxGLAndroidSDKTestApp/build.gradle | 2 +- platform/android/build.gradle | 1 - platform/android/gradle/dependencies.gradle | 25 ++++------ platform/android/gradle/gradle-publish.gradle | 46 ------------------ .../gradle-update-vendor-modules.gradle | 3 -- platform/android/settings.gradle | 8 +--- 9 files changed, 68 insertions(+), 89 deletions(-) delete mode 100644 platform/android/gradle/gradle-update-vendor-modules.gradle diff --git a/Makefile b/Makefile index 880abe1f99a..15802768c6f 100644 --- a/Makefile +++ b/Makefile @@ -517,13 +517,8 @@ android-style-code: node platform/android/scripts/generate-style-code.js style-code: android-style-code -# Vendor submodules configuration for Android. -.PHONY: platform/android/vendor -platform/android/vendor: - git submodule update --init --recursive platform/android/vendor - # Configuration file for running CMake from Gradle within Android Studio. -platform/android/gradle/configuration.gradle: platform/android/vendor +platform/android/gradle/configuration.gradle: @printf "ext {\n node = '`command -v node || command -v nodejs`'\n npm = '`command -v npm`'\n ccache = '`command -v ccache`'\n}" > $@ define ANDROID_RULES @@ -763,11 +758,6 @@ endif android-configuration: platform/android/gradle/configuration.gradle cat platform/android/gradle/configuration.gradle -# Updates Android's vendor submodules -.PHONY: android-update-vendor -android-update-vendor: platform/android/gradle/configuration.gradle - cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none updateVendorSubmodules - # Creates a dependency graph using Graphviz .PHONY: android-graph android-graph: platform/android/gradle/configuration.gradle diff --git a/platform/android/LICENSE.md b/platform/android/LICENSE.md index 93c3edfcd9a..f69b3935416 100644 --- a/platform/android/LICENSE.md +++ b/platform/android/LICENSE.md @@ -18,6 +18,18 @@ License: [The Apache Software License, Version 2.0](http://www.apache.org/licens =========================================================================== +Mapbox GL uses portions of the Android Lifecycle Extensions. +URL: [https://developer.android.com/topic/libraries/architecture/index.html](https://developer.android.com/topic/libraries/architecture/index.html) +License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) + +=========================================================================== + +Mapbox GL uses portions of the Android Lifecycle LiveData. +URL: [https://developer.android.com/topic/libraries/architecture/index.html](https://developer.android.com/topic/libraries/architecture/index.html) +License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) + +=========================================================================== + Mapbox GL uses portions of the Android Lifecycle LiveData Core. URL: [https://developer.android.com/topic/libraries/architecture/index.html](https://developer.android.com/topic/libraries/architecture/index.html) License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -94,6 +106,42 @@ License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) =========================================================================== +Mapbox GL uses portions of the Mapbox Android Core Library. +URL: [https://github.com/mapbox/mapbox-events-android](https://github.com/mapbox/mapbox-events-android) +License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) + +=========================================================================== + +Mapbox GL uses portions of the Mapbox Android Gestures Library. +URL: [https://github.com/mapbox/mapbox-gestures-android](https://github.com/mapbox/mapbox-gestures-android) +License: [BSD 2-Clause "Simplified" License](https://raw.githubusercontent.com/mapbox/mapbox-gestures-android/master/LICENSE.md) + +=========================================================================== + +Mapbox GL uses portions of the Mapbox Android Telemetry Library. +URL: [https://github.com/mapbox/mapbox-events-android](https://github.com/mapbox/mapbox-events-android) +License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) + +=========================================================================== + +Mapbox GL uses portions of the Mapbox Services SDK. +URL: [https://github.com/mapbox/mapbox-java](https://github.com/mapbox/mapbox-java) +License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) + +=========================================================================== + +Mapbox GL uses portions of the Mapbox Services SDK. +URL: [https://github.com/mapbox/mapbox-java](https://github.com/mapbox/mapbox-java) +License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) + +=========================================================================== + +Mapbox GL uses portions of the Mapbox Services SDK. +URL: [https://github.com/mapbox/mapbox-java](https://github.com/mapbox/mapbox-java) +License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) + +=========================================================================== + Mapbox GL uses portions of the OkHttp. License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index e6f4cab847a..eafb0583c24 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -4,11 +4,13 @@ apply plugin: 'kotlin-android' dependencies { lintChecks project(":MapboxGLAndroidSDKLint") - api project(":libcore") - api project(":libtelemetry") - api project(":MapboxAndroidGestures") - api project(":services-geojson") - implementation project(":services-turf") + api dependenciesList.mapboxAndroidTelemetry + api dependenciesList.mapboxJavaGeoJSON + api (dependenciesList.mapboxAndroidGestures) { + // workaround until https://github.com/mapbox/mapbox-gestures-android/issues/50 is released + exclude group: 'com.jakewharton.timber', module: 'timber' + } + implementation dependenciesList.mapboxJavaTurf implementation dependenciesList.supportAppcompatV7 implementation dependenciesList.supportAnnotations implementation dependenciesList.supportFragmentV4 diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle index cc56e002f7d..b61397b7c16 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle +++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle @@ -57,7 +57,7 @@ dependencies { implementation dependenciesList.kotlinLib implementation project(':MapboxGLAndroidSDK') - implementation project(":services-turf") + implementation dependenciesList.mapboxJavaTurf implementation dependenciesList.supportAppcompatV7 implementation dependenciesList.supportRecyclerView diff --git a/platform/android/build.gradle b/platform/android/build.gradle index f1d88e3dc60..e75909c83a2 100644 --- a/platform/android/build.gradle +++ b/platform/android/build.gradle @@ -1,5 +1,4 @@ buildscript { - apply from: "${rootDir}/gradle/gradle-update-vendor-modules.gradle" apply from: "${rootDir}/gradle/dependencies.gradle" repositories { diff --git a/platform/android/gradle/dependencies.gradle b/platform/android/gradle/dependencies.gradle index d6dad86f728..0349738b493 100644 --- a/platform/android/gradle/dependencies.gradle +++ b/platform/android/gradle/dependencies.gradle @@ -7,6 +7,9 @@ ext { ] versions = [ + mapboxServices : '4.3.0', + mapboxTelemetry : '4.2.0', + mapboxGestures : '0.3.0', supportLib : '27.1.1', constraintLayout: '1.1.2', espresso : '3.0.2', @@ -25,23 +28,15 @@ ext { reLinker : '1.3.1' ] - vendorArtifacts = [ - mapboxGestures : 'mapbox-android-gestures', - mapboxJavaCore : 'mapbox-sdk-core', - mapboxJavaTurf : 'mapbox-sdk-turf', - mapboxJavaGeojson: 'mapbox-sdk-geojson', - mapboxTelemetry : 'mapbox-android-telemetry', - mapboxAndroidCore: 'mapbox-android-core' - ] + dependenciesList = [ + mapboxJavaServices : "com.mapbox.mapboxsdk:mapbox-sdk-services:${versions.mapboxServices}", + mapboxJavaGeoJSON : "com.mapbox.mapboxsdk:mapbox-sdk-geojson:${versions.mapboxServices}", + mapboxAndroidTelemetry : "com.mapbox.mapboxsdk:mapbox-android-telemetry:${versions.mapboxTelemetry}", + mapboxAndroidGestures : "com.mapbox.mapboxsdk:mapbox-android-gestures:${versions.mapboxGestures}", - vendorVersions = [ - mapboxGestures : '0.3.0', - mapboxJava : '4.3.0', - mapboxTelemetry : '4.2.0', - mapboxAndroidCore: '1.1.0' - ] + // for testApp + mapboxJavaTurf : "com.mapbox.mapboxsdk:mapbox-sdk-turf:${versions.mapboxServices}", - dependenciesList = [ junit : "junit:junit:${versions.junit}", mockito : "org.mockito:mockito-core:${versions.mockito}", mockk : "io.mockk:mockk:${versions.mockk}", diff --git a/platform/android/gradle/gradle-publish.gradle b/platform/android/gradle/gradle-publish.gradle index 3f4686444cc..a3bf83348f1 100644 --- a/platform/android/gradle/gradle-publish.gradle +++ b/platform/android/gradle/gradle-publish.gradle @@ -1,6 +1,5 @@ apply plugin: 'maven' apply plugin: 'signing' -apply from: "${rootDir}/gradle/dependencies.gradle" allprojects { group project.GROUP @@ -98,21 +97,6 @@ afterEvaluate { project -> } } } - - def vendorMap = getVendorMap() - pom.whenConfigured { pom -> - println("Current dependencies ${pom.dependencies}") - pom.dependencies.each { dep -> - println("Processing vendor ${dep}") - if (dep.getGroupId() == rootProject.name) { - Vendor vendor = vendorMap.get(dep.getArtifactId()) - dep.setGroupId(project.GROUP) - dep.setArtifactId(vendor.artifactName) - dep.setVersion(vendor.artifactVersion) - println("Updated vendor ${dep}") - } - } - } } } } @@ -157,33 +141,3 @@ afterEvaluate { project -> } } } - -// this class holds values that will be included in the resulting pom file for vendorized libraries -class Vendor { - private final artifactName - private final artifactVersion - - Vendor(artifactName, artifactVersion) { - this.artifactName = artifactName - this.artifactVersion = artifactVersion - } - - def getArtifactName() { - return artifactName - } - - def getArtifactVersion() { - return artifactVersion - } -} - -HashMap getVendorMap() { - def map = new HashMap() - map.put("mapbox-android-gestures", new Vendor(vendorArtifacts.mapboxGestures, vendorVersions.mapboxGestures)) - map.put("services-core", new Vendor(vendorArtifacts.mapboxJavaCore, vendorVersions.mapboxJava)) - map.put("services-turf", new Vendor(vendorArtifacts.mapboxJavaTurf, vendorVersions.mapboxJava)) - map.put("services-geojson", new Vendor(vendorArtifacts.mapboxJavaGeojson, vendorVersions.mapboxJava)) - map.put("libcore", new Vendor(vendorArtifacts.mapboxAndroidCore, vendorVersions.mapboxAndroidCore)) - map.put("libtelemetry", new Vendor(vendorArtifacts.mapboxTelemetry, vendorVersions.mapboxTelemetry)) - return map -} \ No newline at end of file diff --git a/platform/android/gradle/gradle-update-vendor-modules.gradle b/platform/android/gradle/gradle-update-vendor-modules.gradle deleted file mode 100644 index 2b8128d2113..00000000000 --- a/platform/android/gradle/gradle-update-vendor-modules.gradle +++ /dev/null @@ -1,3 +0,0 @@ -task updateVendorSubmodules { - "git submodule update --init --recursive vendor".execute() -} \ No newline at end of file diff --git a/platform/android/settings.gradle b/platform/android/settings.gradle index b5fb30106d6..c0315fed04f 100644 --- a/platform/android/settings.gradle +++ b/platform/android/settings.gradle @@ -1,7 +1 @@ -include ':MapboxGLAndroidSDK', ':MapboxGLAndroidSDKTestApp', ':MapboxGLAndroidSDKLint', ':MapboxAndroidGestures', ':services-core', ':services-geojson', ':services-turf', ':libtelemetry', ':libcore' -project(':MapboxAndroidGestures').projectDir = new File('vendor/mapbox-gestures-android/library') -project(':services-core').projectDir = new File('vendor/mapbox-java/services-core') -project(':services-geojson').projectDir = new File('vendor/mapbox-java/services-geojson') -project(':services-turf').projectDir = new File('vendor/mapbox-java/services-turf') -project(':libtelemetry').projectDir = new File('vendor/mapbox-events-android/libtelemetry') -project(':libcore').projectDir = new File('vendor/mapbox-events-android/libcore') \ No newline at end of file +include ':MapboxGLAndroidSDK', ':MapboxGLAndroidSDKTestApp', ':MapboxGLAndroidSDKLint' \ No newline at end of file From d38c65b3bb184681fbc82a9c892c73839d60bbf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Mon, 28 Jan 2019 13:10:06 +0100 Subject: [PATCH 2/4] [android] android nitpick script, verify submodule pins (cherry picked from commit e598146399a9d53a2d78b3b45eb1a69ca367dcf3) --- Makefile | 10 ++++ circle.yml | 6 +++ .../android/MapboxGLAndroidSDK/build.gradle | 4 +- .../android/gradle/android-nitpick.gradle | 53 +++++++++++++++++++ .../gradle-update-vendor-modules.gradle | 5 ++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 platform/android/gradle/android-nitpick.gradle create mode 100644 platform/android/gradle/gradle-update-vendor-modules.gradle diff --git a/Makefile b/Makefile index 15802768c6f..4dd599bb96a 100644 --- a/Makefile +++ b/Makefile @@ -758,6 +758,16 @@ endif android-configuration: platform/android/gradle/configuration.gradle cat platform/android/gradle/configuration.gradle +# Updates Android's vendor submodules +.PHONY: android-update-vendor +android-update-vendor: platform/android/gradle/configuration.gradle + cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none updateVendorSubmodules + +# Run android nitpick script +.PHONY: run-android-nitpick +run-android-nitpick: android-update-vendor + cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none androidNitpick + # Creates a dependency graph using Graphviz .PHONY: android-graph android-graph: platform/android/gradle/configuration.gradle diff --git a/circle.yml b/circle.yml index c7f2d322500..11291984c6d 100644 --- a/circle.yml +++ b/circle.yml @@ -535,6 +535,9 @@ jobs: MBGL_ANDROID_STL: << parameters.stl >> steps: - install-dependencies: { gradle: true } + - run: + name: Android nitpick + command: make run-android-nitpick - run: name: Check code style command: make android-check @@ -596,6 +599,9 @@ jobs: IS_LOCAL_DEVELOPMENT: false steps: - install-dependencies: { gradle: true } + - run: + name: Android nitpick + command: make run-android-nitpick - run: name: Generate Maven credentials command: | diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index eafb0583c24..12be290175b 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -165,4 +165,6 @@ configurations { apply from: "${rootDir}/gradle/gradle-javadoc.gradle" apply from: "${rootDir}/gradle/gradle-publish.gradle" apply from: "${rootDir}/gradle/gradle-checkstyle.gradle" -apply from: "${rootDir}/gradle/gradle-dependencies-graph.gradle" \ No newline at end of file +apply from: "${rootDir}/gradle/gradle-dependencies-graph.gradle" +apply from: "${rootDir}/gradle/gradle-update-vendor-modules.gradle" +apply from: "${rootDir}/gradle/android-nitpick.gradle" \ No newline at end of file diff --git a/platform/android/gradle/android-nitpick.gradle b/platform/android/gradle/android-nitpick.gradle new file mode 100644 index 00000000000..dfcbcfb869a --- /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 diff --git a/platform/android/gradle/gradle-update-vendor-modules.gradle b/platform/android/gradle/gradle-update-vendor-modules.gradle new file mode 100644 index 00000000000..f2305eb7a53 --- /dev/null +++ b/platform/android/gradle/gradle-update-vendor-modules.gradle @@ -0,0 +1,5 @@ +task updateVendorSubmodules { + doLast { + "git submodule update --init --recursive vendor".execute() + } +} \ No newline at end of file From c87b09cbb430afb0e71354dbd94c2ecab0bc206c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Tue, 29 Jan 2019 15:46:55 +0100 Subject: [PATCH 3/4] [android] run vendor submodule check --- .../android/gradle/android-nitpick.gradle | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/platform/android/gradle/android-nitpick.gradle b/platform/android/gradle/android-nitpick.gradle index dfcbcfb869a..e79a23e6bf1 100644 --- a/platform/android/gradle/android-nitpick.gradle +++ b/platform/android/gradle/android-nitpick.gradle @@ -9,26 +9,25 @@ def MAPBOX_TELEMETRY_TAG_PREFIX = 'telem-' def MAPBOX_GESTURES_DIR = 'mapbox-gestures-android' def MAPBOX_GESTURES_TAG_PREFIX = 'v' -task verifyVendorSubmodulePins { +task androidNitpick { doLast { + println "Running android nitpick script" + println "Verify vendor submodule pins" + exec { + workingDir = "${rootDir}" + commandLine "git", "submodule", "update", "--init", "--recursive", "vendor" + } 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}" + workingDir = "${rootDir}/vendor/${dir}" commandLine "git", "rev-list", "-n", "1", "tags/${prefix + version}" standardOutput = output } @@ -36,7 +35,7 @@ private def verifyVendorSubmodulePin(def dir, def prefix, def version) { output.reset() exec { - workingDir "${rootDir}/vendor/${dir}" + workingDir = "${rootDir}/vendor/${dir}" commandLine "git", "rev-parse", "HEAD" standardOutput = output } From f5195ef78ea37b915677a2704778fa3078e14e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Tue, 29 Jan 2019 18:14:16 +0100 Subject: [PATCH 4/4] [android] sync vendor pins --- platform/android/vendor/mapbox-events-android | 2 +- platform/android/vendor/mapbox-gestures-android | 2 +- platform/android/vendor/mapbox-java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/android/vendor/mapbox-events-android b/platform/android/vendor/mapbox-events-android index 20c31407f25..1636d1ae9d5 160000 --- a/platform/android/vendor/mapbox-events-android +++ b/platform/android/vendor/mapbox-events-android @@ -1 +1 @@ -Subproject commit 20c31407f259961db0602137a52f33ba5e580dde +Subproject commit 1636d1ae9d5b0f0dd2367c8f32f1af958640b14e diff --git a/platform/android/vendor/mapbox-gestures-android b/platform/android/vendor/mapbox-gestures-android index 9d105dce2a4..5d2bcdc6d2e 160000 --- a/platform/android/vendor/mapbox-gestures-android +++ b/platform/android/vendor/mapbox-gestures-android @@ -1 +1 @@ -Subproject commit 9d105dce2a495d1605fbab75829d33278ae7318b +Subproject commit 5d2bcdc6d2e30d002d65f38fd2726b094e086c44 diff --git a/platform/android/vendor/mapbox-java b/platform/android/vendor/mapbox-java index 22a324ffc37..f21558ad039 160000 --- a/platform/android/vendor/mapbox-java +++ b/platform/android/vendor/mapbox-java @@ -1 +1 @@ -Subproject commit 22a324ffc37389cebee20aa49e83c08c13221a98 +Subproject commit f21558ad03967d7600a47ae61bc693898ce5bd6f