diff --git a/.circleci/config.yml b/.circleci/config.yml index 79e3b4a..12b953a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,13 @@ version: 2.1 + +executors: + ndk-r21e-latest-executor: + docker: + - image: mbgl/android-ndk-r21e:latest + working_directory: ~/code + environment: + MBX_CI_DOMAIN: o619qyc20d.execute-api.us-east-1.amazonaws.com + commands: restore-gradle-cache: steps: @@ -14,6 +23,15 @@ commands: - ~/.gradle key: v1-dependencies-{{ checksum "build.gradle.kts" }}-{{ checksum "annotations/build.gradle.kts" }}-{{ checksum "annotations-processor/build.gradle.kts" }}-{{ checksum "common/build.gradle.kts" }}-{{ checksum "liblogger/build.gradle.kts" }} + install-mbx-ci: + steps: + - run: + name: Install mbx-ci + command: | + curl -Ls https://mapbox-release-engineering.s3.amazonaws.com/mbx-ci/latest/mbx-ci-linux-amd64 > mbx-ci + chmod 755 ./mbx-ci + ./mbx-ci aws setup + run-unit-tests: steps: - run: @@ -50,41 +68,22 @@ commands: name: Build libraries for debug command: make buildDebug - update-version-name: - steps: - - run: - name: Update version name - command: | - if [[ $CIRCLE_TAG == v* ]]; then - sed -i -e "s/^VERSION_NAME=.*/VERSION_NAME=${CIRCLE_TAG:1}/" gradle.properties - fi - publish: steps: - - run: - name: Generate Bintray credentials - command: | - if [ -n "${BINTRAY_USER}" ]; then - echo "BINTRAY_USER=$BINTRAY_USER - BINTRAY_API_KEY=$BINTRAY_API_KEY - GPG_PASSPHRASE=$GPG_PASSPHRASE" - fi - deploy: - name: Publish Base SDK artifacts to Bintray + name: Publish Base SDK artifacts to SDK Registry command: | - if [[ $CIRCLE_BRANCH == master ]] || [[ $CIRCLE_TAG == v* ]]; then - version=$(cat gradle.properties | grep "VERSION_NAME") - if [[ $version != *"SNAPSHOT"* ]]; then - make bintrayPublish - else - make artifactoryPublish - fi + version=$(cat gradle.properties | grep "VERSION_NAME") + if [[ $CIRCLE_BRANCH == master && $version == *"SNAPSHOT"* ]]; then + make sdkRegistryPublish + elif [[ $CIRCLE_TAG == v* ]]; then + sed -i -e "s/^VERSION_NAME=.*/VERSION_NAME=${CIRCLE_TAG:1}/" gradle.properties + make sdkRegistryPublish fi jobs: verify-code: - docker: - - image: mbgl/android-ndk-r21b:latest + executor: ndk-r21e-latest-executor steps: - checkout - restore-gradle-cache @@ -94,28 +93,25 @@ jobs: - validate-dokka-docs build-release: - docker: - - image: mbgl/android-ndk-r21b:latest + executor: ndk-r21e-latest-executor steps: - checkout - restore-gradle-cache - build-release-libraries build-debug: - docker: - - image: mbgl/android-ndk-r21b:latest + executor: ndk-r21e-latest-executor steps: - checkout - restore-gradle-cache - build-debug-libraries release: - docker: - - image: mbgl/android-ndk-r21b:latest + executor: ndk-r21e-latest-executor steps: - checkout - restore-gradle-cache - - update-version-name + - install-mbx-ci - build-release-libraries - publish @@ -135,4 +131,4 @@ workflows: - verify-code filters: tags: - only: /v.*/ \ No newline at end of file + only: /v.*/ diff --git a/Makefile b/Makefile index 30bcc62..1b3e4e4 100644 --- a/Makefile +++ b/Makefile @@ -20,22 +20,14 @@ buildRelease: ./gradlew liblogger:assembleRelease && \ ./gradlew libloader:assembleRelease -.PHONY: bintrayPublish -bintrayPublish: - ./gradlew :annotations:bintrayUpload ; \ - ./gradlew :annotations-processor:bintrayUpload ; \ - ./gradlew :common:bintrayUpload ; \ - ./gradlew :liblogger:bintrayUpload ; \ - ./gradlew :libloader:bintrayUpload ; \ - -.PHONY: artifactoryPublish -artifactoryPublish: - ./gradlew :annotations:artifactoryPublish ; \ - ./gradlew :annotations-processor:artifactoryPublish ; \ - ./gradlew :common:artifactoryPublish ; \ - ./gradlew :liblogger:artifactoryPublish ; \ - ./gradlew :libloader:artifactoryPublish ; \ +.PHONY: sdkRegistryPublish +sdkRegistryPublish: + ./gradlew :annotations:mapboxSDKRegistryUpload ; \ + ./gradlew :annotations-processor:mapboxSDKRegistryUpload ; \ + ./gradlew :common:mapboxSDKRegistryUpload ; \ + ./gradlew :liblogger:mapboxSDKRegistryUpload ; \ + ./gradlew :libloader:mapboxSDKRegistryUpload ; \ .PHONY: runUnitTests runUnitTests: - ./gradlew test \ No newline at end of file + ./gradlew test diff --git a/README.md b/README.md index 9b590c4..6675dfb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,16 @@ ## Mapbox Base Android This repository hosts annotation processors and module providers for Mapbox modular SDKs. -For documentation see [MODULARIZATION.md](https://github.com/mapbox/mapbox-base-android/blob/master/MODULARIZATION.md). \ No newline at end of file +For documentation see [MODULARIZATION.md](https://github.com/mapbox/mapbox-base-android/blob/master/MODULARIZATION.md). + +## Configure credentials +Before installing the SDK, you will need to gather sensitive information from your Mapbox account. +If you don't have a Mapbox account: [sign up](https://account.mapbox.com/auth/signup/) and navigate to your [Account page](https://account.mapbox.com/). +You'll need a secret access token with the `Downloads:Read` scope: +1. From your account's [tokens page](https://account.mapbox.com/access-tokens/), click the **Create a token** button. +2. From the token creation page, give your token a name and make sure the box next to the `Downloads:Read` scope is checked. +3. Click the **Create token** button at the bottom of the page to create your token. +4. The token you've created is a *secret token*, which means you will only have one opportunity to copy it somewhere secure. + +You should not expose these access tokens in publicly-accessible source code where unauthorized users might find them. Instead, you should store them somewhere safe on your computer and take advantage of [Gradle properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties) to make sure they're only added when your app is compiled. Once this configuration step has been completed, you will be able to reference your credentials in other parts of your app. + diff --git a/annotations-processor/build.gradle.kts b/annotations-processor/build.gradle.kts index 23f7b57..edb737d 100644 --- a/annotations-processor/build.gradle.kts +++ b/annotations-processor/build.gradle.kts @@ -15,5 +15,5 @@ dependencies { project.apply { from("$rootDir/gradle/ktlint.gradle") from("$rootDir/gradle/java-artifacts.gradle") - from("$rootDir/gradle/bintray-publish.gradle") + from("$rootDir/gradle/sdk-registry-publish.gradle") } diff --git a/annotations-processor/gradle.properties b/annotations-processor/gradle.properties index 9c68b45..286a3db 100644 --- a/annotations-processor/gradle.properties +++ b/annotations-processor/gradle.properties @@ -3,4 +3,5 @@ POM_ARTIFACT_ID=annotations-processor POM_ARTIFACT_GROUP_ID=com.mapbox.base POM_ARTIFACT_TITLE=Mapbox Annotations Processor POM_DESCRIPTION=Artifact that provides Mapbox module and plugin generators -BINTRAY_PROJECT_NAME=annotations-processor \ No newline at end of file + +REGISTRY_SDK_NAME=com-mapbox-base-annotations-processor diff --git a/annotations/build.gradle.kts b/annotations/build.gradle.kts index 3aeb1fd..4aa50bf 100644 --- a/annotations/build.gradle.kts +++ b/annotations/build.gradle.kts @@ -15,5 +15,5 @@ dependencies { project.apply { from("$rootDir/gradle/ktlint.gradle") from("$rootDir/gradle/java-artifacts.gradle") - from("$rootDir/gradle/bintray-publish.gradle") + from("$rootDir/gradle/sdk-registry-publish.gradle") } diff --git a/annotations/gradle.properties b/annotations/gradle.properties index b4e8aab..d674db0 100644 --- a/annotations/gradle.properties +++ b/annotations/gradle.properties @@ -3,4 +3,5 @@ POM_ARTIFACT_ID=annotations POM_ARTIFACT_GROUP_ID=com.mapbox.base POM_ARTIFACT_TITLE=Mapbox Annotations POM_DESCRIPTION=Artifact that provides Mapbox module and plugin annotations -BINTRAY_PROJECT_NAME=annotations \ No newline at end of file + +REGISTRY_SDK_NAME=com-mapbox-base-annotations diff --git a/build.gradle.kts b/build.gradle.kts index c8e6cc9..5ff133e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,15 +2,29 @@ buildscript { repositories { google() jcenter() + + maven { + authentication { + create("basic") + } + url = uri("https://api.mapbox.com/downloads/v2/releases/maven") + credentials { + username = "mapbox" + password = if (project.hasProperty("SDK_REGISTRY_TOKEN")) { + project.property("SDK_REGISTRY_TOKEN") as String + } else { + System.getenv("SDK_REGISTRY_TOKEN") + } ?: throw IllegalArgumentException("SDK Registry key is not specified") + } + } } + dependencies { classpath(Plugins.android) classpath(Plugins.kotlin) classpath(Plugins.license) classpath(Plugins.dokka) - classpath(Plugins.androidPublish) - classpath(Plugins.bintray) - classpath(Plugins.artifactory) + classpath(Plugins.sdkRegistry) } } @@ -18,6 +32,7 @@ allprojects { repositories { google() jcenter() + maven { authentication { create("basic") diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index fd53639..44bb323 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -10,7 +10,7 @@ plugins { } dependencies { - implementation("com.android.tools.build:gradle:4.0.1") + implementation("com.android.tools.build:gradle:4.1.3") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10") implementation(gradleApi()) implementation(localGroovy()) diff --git a/buildSrc/src/main/kotlin/Project.kt b/buildSrc/src/main/kotlin/Project.kt index 841ded2..81391a5 100644 --- a/buildSrc/src/main/kotlin/Project.kt +++ b/buildSrc/src/main/kotlin/Project.kt @@ -9,9 +9,7 @@ object Plugins { const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}" const val license = "com.jaredsburrows:gradle-license-plugin:${Versions.license}" const val dokka = "org.jetbrains.dokka:dokka-android-gradle-plugin:${Versions.dokka}" - const val bintray = "com.jfrog.bintray.gradle:gradle-bintray-plugin:${Versions.bintray}" - const val androidPublish = "digital.wup:android-maven-publish:${Versions.androidPublish}" - const val artifactory = "org.jfrog.buildinfo:build-info-extractor-gradle:${Versions.artifactory}" + const val sdkRegistry = "com.mapbox.gradle.plugins:sdk-registry:${Versions.sdkRegistry}" } object Dependencies { @@ -25,16 +23,14 @@ object Dependencies { } private object Versions { - const val tools = "4.0.1" + const val tools = "4.1.3" const val kotlin = "1.4.10" const val androidX = "1.1.0" const val license = "0.8.5" const val kotlinPoet = "1.6.0" const val serviceProvider = "1.0-rc7" const val dokka = "0.9.18" - const val bintray = "1.8.4" - const val androidPublish = "3.6.2" - const val artifactory = "4.17.2" + const val sdkRegistry = "0.7.0" const val mockk = "1.10.0" const val junit = "1.1.2" const val navigationBase = "1.0.0-rc.6" @@ -49,7 +45,4 @@ object ArtifactSettings { const val artifactScmUrl = "scm:git@github.com:mapbox/mapbox-base-android.git" const val artifactLicenseName = "BSD" const val artifactLicenseUrl = "https://opensource.org/licenses/BSD-2-Clause" - - const val bintrayUserOrg = "mapbox" - const val bintrayRepoName = "mapbox" } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index daa632b..21d030b 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -34,5 +34,5 @@ project.apply { from("$rootDir/gradle/ktlint.gradle") from("$rootDir/gradle/lint.gradle") from("$rootDir/gradle/android-artifacts.gradle") - from("$rootDir/gradle/bintray-publish.gradle") + from("$rootDir/gradle/sdk-registry-publish.gradle") } \ No newline at end of file diff --git a/common/gradle.properties b/common/gradle.properties index 813e0b9..2b970aa 100644 --- a/common/gradle.properties +++ b/common/gradle.properties @@ -3,6 +3,7 @@ POM_ARTIFACT_ID=common POM_ARTIFACT_GROUP_ID=com.mapbox.base POM_ARTIFACT_TITLE=Mapbox Common POM_DESCRIPTION=Artifact that provides Mapbox module and plugin contracts -BINTRAY_PROJECT_NAME=common -android.useAndroidX = true \ No newline at end of file +REGISTRY_SDK_NAME=com-mapbox-base-common + +android.useAndroidX = true diff --git a/gradle.properties b/gradle.properties index b90c536..d7ee93c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -VERSION_NAME=0.5.0-SNAPSHOT +VERSION_NAME=0.6.0-SNAPSHOT diff --git a/gradle/artifact-settings.gradle b/gradle/artifact-settings.gradle index b187dfa..2520088 100644 --- a/gradle/artifact-settings.gradle +++ b/gradle/artifact-settings.gradle @@ -5,19 +5,16 @@ ext { mapboxArtifactDescription = project.property('POM_DESCRIPTION') mapboxDeveloperName = 'Mapbox' mapboxDeveloperId = 'mapbox' + mapboxArtifactUrl = 'https://github.com/mapbox/mapbox-base-android' mapboxArtifactVcsUrl = 'https://github.com/mapbox/mapbox-base-android.git' mapboxArtifactScmUrl = 'scm:git@github.com:mapbox/mapbox-base-android.git' mapboxArtifactLicenseName = 'BSD' mapboxArtifactLicenseUrl = 'https://opensource.org/licenses/BSD-2-Clause' + versionName = project.property('VERSION_NAME') - mapboxBintrayUserOrg = 'mapbox' - mapboxBintrayRepoName = 'mapbox' - mapboxBintrayProjectName = project.property('BINTRAY_PROJECT_NAME') - mapboxBintrayUser = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - mapboxBintrayApiKey = project.hasProperty('BINTRAY_API_KEY') ? project.property('BINTRAY_API_KEY') : System.getenv('BINTRAY_API_KEY') - mapboxGpgPassphrase = project.hasProperty('GPG_PASSPHRASE') ? project.property('GPG_PASSPHRASE') : System.getenv('GPG_PASSPHRASE') + registrySdkName = project.property('REGISTRY_SDK_NAME') isAndroidProject = project.property('IS_ANDROID_PROJECT') -} \ No newline at end of file +} diff --git a/gradle/bintray-publish.gradle b/gradle/sdk-registry-publish.gradle similarity index 64% rename from gradle/bintray-publish.gradle rename to gradle/sdk-registry-publish.gradle index a595e5f..64b0e7f 100644 --- a/gradle/bintray-publish.gradle +++ b/gradle/sdk-registry-publish.gradle @@ -1,7 +1,5 @@ -apply plugin: 'digital.wup.android-maven-publish' apply plugin: 'maven-publish' -apply plugin: 'com.jfrog.bintray' -apply plugin: 'com.jfrog.artifactory' +apply plugin: 'com.mapbox.sdkRegistry' apply from: file('../gradle/artifact-settings.gradle') version = project.ext.versionName @@ -12,7 +10,7 @@ publishing { MapboxBasePublication(MavenPublication) { afterEvaluate { if (project.ext.isAndroidProject.toBoolean()) { - from components.android + from components.release artifact(androidSourcesJar) } else { from components.java @@ -49,44 +47,13 @@ publishing { } } -bintray { - user = mapboxBintrayUser - key = mapboxBintrayApiKey - publications('MapboxBasePublication') - pkg { - repo = project.ext.mapboxBintrayRepoName - name = project.ext.mapboxBintrayProjectName - userOrg = project.ext.mapboxBintrayUserOrg - licenses = [project.ext.mapboxArtifactLicenseName] - vcsUrl = project.ext.mapboxArtifactVcsUrl - publish = false - version { - name = project.ext.versionName - desc = project.ext.mapboxArtifactDescription - released = new Date() - gpg { - sign = true - passphrase = mapboxGpgPassphrase - } - mavenCentralSync { - sync = false - } - } - } -} - -artifactory { - contextUrl = 'http://oss.jfrog.org' - publish { - repository { - repoKey = 'oss-snapshot-local' - username = mapboxBintrayUser - password = mapboxBintrayApiKey - } - defaults { - publications('MapboxBasePublication') - } - } +registry { + sdkName = project.properties['registrySdkName'] + production = true + snapshot = versionName.endsWith("-SNAPSHOT") + override = snapshot ? true : false + dryRun = project.properties['sdkRegistryDryRun'] ?: false + publications = ["MapboxBasePublication"] } task javadocsJar(type: Jar, dependsOn: dokka) { @@ -98,4 +65,4 @@ tasks.withType(Javadoc) { options.addStringOption('encoding', 'UTF-8') options.addStringOption('docencoding', 'UTF-8') options.addStringOption('charset', 'UTF-8') -} \ No newline at end of file +} diff --git a/libloader/build.gradle.kts b/libloader/build.gradle.kts index daa9c54..fb78319 100644 --- a/libloader/build.gradle.kts +++ b/libloader/build.gradle.kts @@ -35,5 +35,5 @@ project.apply { from("$rootDir/gradle/ktlint.gradle") from("$rootDir/gradle/lint.gradle") from("$rootDir/gradle/android-artifacts.gradle") - from("$rootDir/gradle/bintray-publish.gradle") + from("$rootDir/gradle/sdk-registry-publish.gradle") } \ No newline at end of file diff --git a/libloader/gradle.properties b/libloader/gradle.properties index 222636b..9687b18 100644 --- a/libloader/gradle.properties +++ b/libloader/gradle.properties @@ -3,6 +3,7 @@ POM_ARTIFACT_ID=loader POM_ARTIFACT_GROUP_ID=com.mapbox.common POM_ARTIFACT_TITLE=Mapbox LibraryLoader POM_DESCRIPTION=Artifact that provides Mapbox LibraryLoader module implementation -BINTRAY_PROJECT_NAME=com.mapbox.common:loader -android.useAndroidX = true \ No newline at end of file +REGISTRY_SDK_NAME=com-mapbox-common-loader + +android.useAndroidX = true diff --git a/liblogger/build.gradle.kts b/liblogger/build.gradle.kts index daa9c54..fb78319 100644 --- a/liblogger/build.gradle.kts +++ b/liblogger/build.gradle.kts @@ -35,5 +35,5 @@ project.apply { from("$rootDir/gradle/ktlint.gradle") from("$rootDir/gradle/lint.gradle") from("$rootDir/gradle/android-artifacts.gradle") - from("$rootDir/gradle/bintray-publish.gradle") + from("$rootDir/gradle/sdk-registry-publish.gradle") } \ No newline at end of file diff --git a/liblogger/gradle.properties b/liblogger/gradle.properties index 4677d46..df2cead 100644 --- a/liblogger/gradle.properties +++ b/liblogger/gradle.properties @@ -3,6 +3,7 @@ POM_ARTIFACT_ID=logger POM_ARTIFACT_GROUP_ID=com.mapbox.common POM_ARTIFACT_TITLE=Mapbox Logger POM_DESCRIPTION=Artifact that provides Mapbox Logger module implementation -BINTRAY_PROJECT_NAME=com.mapbox.common:logger -android.useAndroidX = true \ No newline at end of file +REGISTRY_SDK_NAME=com-mapbox-common-logger + +android.useAndroidX = true diff --git a/liblogger/src/main/java/com/mapbox/common/logger/MapboxLogger.kt b/liblogger/src/main/java/com/mapbox/common/logger/MapboxLogger.kt index c7dab9f..31221b9 100644 --- a/liblogger/src/main/java/com/mapbox/common/logger/MapboxLogger.kt +++ b/liblogger/src/main/java/com/mapbox/common/logger/MapboxLogger.kt @@ -25,7 +25,7 @@ object MapboxLogger : Logger { */ @LogLevel @Volatile - var logLevel: Int = VERBOSE + var logLevel: Int = ERROR /** * [LoggerObserver] for observe any log events