diff options
author | Łukasz Paczos <lukas.paczos@gmail.com> | 2019-03-06 15:46:47 +0100 |
---|---|---|
committer | Łukasz Paczos <lukasz.paczos@mapbox.com> | 2019-03-07 18:46:51 +0100 |
commit | d1109257dc4c47fe45b5c03816c46698e5d7a384 (patch) | |
tree | ca82fb4d97af734642c821a05c7cf8595f81a75a /platform | |
parent | 13a6f4c3dbd9f734dae0f0e3941748d912add449 (diff) | |
download | qtlocation-mapboxgl-d1109257dc4c47fe45b5c03816c46698e5d7a384.tar.gz |
[android] build correct POM when publishing to maven
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/build.gradle | 4 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/gradle.properties | 18 | ||||
-rw-r--r-- | platform/android/build.gradle | 2 | ||||
-rw-r--r-- | platform/android/gradle/artifact-settings.gradle | 24 | ||||
-rw-r--r-- | platform/android/gradle/dependencies.gradle | 4 | ||||
-rw-r--r-- | platform/android/gradle/gradle-bintray.gradle | 159 | ||||
-rw-r--r-- | platform/android/gradle/gradle-publish.gradle | 143 |
7 files changed, 85 insertions, 269 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index 110028b67f..257da91b6b 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -1,9 +1,6 @@ apply plugin: 'com.android.library' apply plugin: "com.jaredsburrows.license" apply plugin: 'kotlin-android' -apply plugin: 'com.jfrog.bintray' -apply plugin: 'maven-publish' -apply plugin: 'com.github.dcendents.android-maven' dependencies { lintChecks project(":MapboxGLAndroidSDKLint") @@ -168,7 +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" apply from: "${rootDir}/gradle/gradle-update-vendor-modules.gradle" diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index a2c56b40bf..be4246a903 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,23 +1,5 @@ -GROUP=com.mapbox.mapboxsdk VERSION_NAME=7.3.0-SNAPSHOT -POM_DESCRIPTION=Mapbox Maps SDK for Android -POM_URL=https://github.com/mapbox/mapbox-gl-native -POM_SCM_URL=https://github.com/mapbox/mapbox-gl-native -POM_SCM_CONNECTION=scm:git@github.com:mapbox/mapbox-gl-native.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:mapbox/mapbox-gl-native.git -POM_VCS_URL=https://github.com/mapbox/mapbox-gl-native.git -POM_LICENCE_NAME=The 2-Clause BSD License -POM_LICENCE_URL=https://opensource.org/licenses/BSD-2-Clause -POM_LICENCE_DIST=repo -POM_DEVELOPER_ID=mapbox -POM_DEVELOPER_NAME=Mapbox -POM_DEVELOPER_GROUP_ID=com.mapbox.mapboxsdk -POM_NAME=Mapbox Maps SDK for Android -POM_ARTIFACT_ID=mapbox-android-sdk -POM_PACKAGING=aar -TRACKER_URL=https://github.com/mapbox/mapbox-gl-native/issues - # Only build native dependencies for the current ABI # See https://code.google.com/p/android/issues/detail?id=221098#c20 android.buildOnlyTargetAbi=true diff --git a/platform/android/build.gradle b/platform/android/build.gradle index 759b7883f9..2ffd91b600 100644 --- a/platform/android/build.gradle +++ b/platform/android/build.gradle @@ -10,7 +10,7 @@ buildscript { classpath dependenciesList.licensesPlugin classpath dependenciesList.kotlinPlugin classpath dependenciesList.bintrayPlugin - classpath dependenciesList.mavenPlugin + classpath dependenciesList.androidPublishPlugin } } diff --git a/platform/android/gradle/artifact-settings.gradle b/platform/android/gradle/artifact-settings.gradle index c9f3753cec..8d86f45c17 100644 --- a/platform/android/gradle/artifact-settings.gradle +++ b/platform/android/gradle/artifact-settings.gradle @@ -1,22 +1,20 @@ ext { - mapboxArtifactDeveloperName = 'Mapbox' mapboxArtifactGroupId = 'com.mapbox.mapboxsdk' + mapboxArtifactId = 'mapbox-android-sdk' + mapboxArtifactTitle = 'Mapbox Maps SDK for Android' + mapboxArtifactDescription = 'Mapbox Maps SDK for Android' + mapboxDeveloperName = 'Mapbox' + mapboxDeveloperId = 'mapbox' mapboxArtifactUrl = 'https://github.com/mapbox/mapbox-gl-native' mapboxArtifactVcsUrl = 'https://github.com/mapbox/mapbox-gl-native.git' - mapboxArtifactTrackerUrl = 'https://github.com/mapbox/mapbox-gl-native/issues' mapboxArtifactScmUrl = 'scm:git@github.com:mapbox/mapbox-gl-native.git' - mapboxArtifactGitUrl = 'https://github.com/mapbox/mapbox-gl-native' - mapboxLicenseName = 'BSD' - mapboxLicenseUrl = 'https://opensource.org/licenses/BSD-2-Clause' - mapboxArtifactInceptionYear = '2014' - versionName = project.hasProperty('versionName') ? project.property('versionName') : System.getenv('VERSION_NAME') + mapboxArtifactLicenseName = 'BSD' + mapboxArtifactLicenseUrl = 'https://opensource.org/licenses/BSD-2-Clause' + versionName = project.hasProperty('VERSION_NAME') ? project.property('VERSION_NAME') : System.getenv('VERSION_NAME') mapboxBintrayUserOrg = 'mapbox' mapboxBintrayRepoName = 'mapbox' - - // mapboxBintrayArtifactId is the same as mapboxArtifactGroup because of a weird bug - // https://github.com/bintray/gradle-bintray-plugin/issues/88 - mapboxArtifactId = 'mapbox-android-sdk' - mapboxArtifactTitle = 'Mapbox Maps SDK for Android' - mapboxArtifactDescription = 'Mapbox Maps SDK for Android' + 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') } diff --git a/platform/android/gradle/dependencies.gradle b/platform/android/gradle/dependencies.gradle index 5def4470ca..8e75541794 100644 --- a/platform/android/gradle/dependencies.gradle +++ b/platform/android/gradle/dependencies.gradle @@ -25,7 +25,7 @@ ext { kotlin : '1.3.11', licenses : '0.8.42', bintray : '1.8.4', - maven : '2.1', + androidPublish : '3.6.2', lint : '26.1.4', gms : '16.0.0', reLinker : '1.3.1' @@ -69,7 +69,7 @@ ext { kotlinPlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}", licensesPlugin : "com.jaredsburrows:gradle-license-plugin:${versions.licenses}", bintrayPlugin : "com.jfrog.bintray.gradle:gradle-bintray-plugin:${versions.bintray}", - mavenPlugin : "com.github.dcendents:android-maven-gradle-plugin:${versions.maven}", + androidPublishPlugin : "digital.wup:android-maven-publish:${versions.androidPublish}", lint : "com.android.tools.lint:lint:${versions.lint}", lintApi : "com.android.tools.lint:lint-api:${versions.lint}", diff --git a/platform/android/gradle/gradle-bintray.gradle b/platform/android/gradle/gradle-bintray.gradle index 7e14a4c1ef..a7e91ec5a5 100644 --- a/platform/android/gradle/gradle-bintray.gradle +++ b/platform/android/gradle/gradle-bintray.gradle @@ -1,119 +1,67 @@ -apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'digital.wup.android-maven-publish' apply plugin: 'maven-publish' +apply plugin: 'com.jfrog.bintray' apply from: file('../gradle/artifact-settings.gradle') - +version = project.ext.versionName group = project.ext.mapboxArtifactGroupId -project.archivesBaseName = project.ext.mapboxArtifactId - -install { - repositories.mavenInstaller { - pom.project { - - // Make sure that artifactId and name are the same String values! - // https://github.com/bintray/gradle-bintray-plugin/issues/81#issuecomment-149632738 - - name project.ext.mapboxArtifactId - println 'name = ' + name - - description project.ext.mapboxArtifactDescription - println 'description = ' + description - url project.ext.mapboxArtifactGitUrl - inceptionYear project.ext.mapboxArtifactInceptionYear - - packaging 'aar' - groupId project.ext.mapboxArtifactGroupId - artifactId project.ext.mapboxArtifactId - version project.ext.versionName - println 'version = ' + version - - scm { - connection project.ext.mapboxArtifactVcsUrl - url project.ext.mapboxArtifactScmUrl - } - - developers { - developer { - name project.ext.mapboxArtifactDeveloperName - } - } - - licenses { - license { - name project.ext.mapboxLicenseName - url project.ext.mapboxLicenseUrl - distribution 'repo' - } - } - } - } -} publishing { publications { MapboxMapsSdkPublication(MavenPublication) { + from components.android + groupId this.group + artifactId project.ext.mapboxArtifactId + version this.version - artifact("$buildDir/outputs/aar/mapbox-android-sdk-release.aar") - - // TODO: Uncomment these and use exisiting Gradle tasks in `gradle-publish.gradle` ? - // TODO: https://github.com/search?q=%22artifact%28sourcesJar%29+++++++++++++artifact%28javadocJar%29%22&type=Code - /*artifact(sourcesJar) - artifact(javadocJar) -*/ - // For some reason, uncommented the following 3 declarations throws an error: - /* - groupId 'com.mapbox.mapboxsdk' - artifactId = 'mapbox-android-sdk' - version project.ext.versionName - */ + afterEvaluate { + artifact("$buildDir/outputs/aar/mapbox-android-sdk-release.aar") + artifact(androidSourcesJar) + artifact(androidJavadocsJar) + } pom.withXml { - def dependenciesNode = asNode().getAt('dependencies')[0] ?: asNode().appendNode('dependencies') - - // Iterate over the implementation dependencies (we don't want the test ones), adding a <dependency> node for each - configurations.implementation.allDependencies.each { - // Ensure dependencies such as fileTree are not included. - if (it.name != 'unspecified') { - def dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', it.group) - dependencyNode.appendNode('artifactId', it.name) - dependencyNode.appendNode('version', it.version) - } - } + final mainNode = asNode() + mainNode.appendNode('name', project.ext.mapboxArtifactTitle) + mainNode.appendNode('description', project.ext.mapboxArtifactTitle) + mainNode.appendNode('url', project.ext.mapboxArtifactUrl) + + final licenseNode = mainNode.appendNode('licenses').appendNode('license') + licenseNode.appendNode('name', project.ext.mapboxArtifactLicenseName) + licenseNode.appendNode('url', project.ext.mapboxArtifactLicenseUrl) + licenseNode.appendNode('distribution', "repo") + + final developerNode = mainNode.appendNode('developers').appendNode('developer') + developerNode.appendNode('id', project.ext.mapboxDeveloperId) + developerNode.appendNode('name', project.ext.mapboxDeveloperName) + + final scmNode = mainNode.appendNode("scm") + scmNode.appendNode("connection", project.ext.mapboxArtifactScmUrl) + scmNode.appendNode("developerConnection", project.ext.mapboxArtifactScmUrl) + scmNode.appendNode("url", project.ext.mapboxArtifactUrl) } } } } bintray { - - user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') - - key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_KEY') - + user = mapboxBintrayUser + key = mapboxBintrayApiKey publications = ['MapboxMapsSdkPublication'] pkg { - repo = project.ext.mapboxBintrayRepoName - println 'pkg repo = ' + repo - name = project.ext.mapboxArtifactId - println 'pkg name = ' + name - userOrg = project.ext.mapboxBintrayUserOrg - println 'pkg userOrg = ' + userOrg - - licenses = [project.ext.mapboxLicenseName] + licenses = [project.ext.mapboxArtifactLicenseName] vcsUrl = project.ext.mapboxArtifactVcsUrl + publish = false version { name = project.ext.versionName - desc = 'Mapbox Maps SDK for Android' + desc = project.ext.mapboxArtifactDescription released = new Date() - println 'version released = ' + released - gpg { sign = true - passphrase = project.hasProperty('gpgPassphrase') ? project.property('gpgPassphrase') : System.getenv('GPG_PASSPHRASE') + passphrase = mapboxGpgPassphrase } mavenCentralSync { sync = false @@ -122,4 +70,39 @@ bintray { } } +task androidJavadocs(type: Javadoc) { + source = android.sourceSets.main.java.sourceFiles + classpath = files(android.bootClasspath) + failOnError = false +} + +task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + classifier = 'javadoc' + from androidJavadocs.destinationDir +} + +task androidSourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.sourceFiles +} + +tasks.withType(Javadoc) { + options.addStringOption('encoding', 'UTF-8') + options.addStringOption('docencoding', 'UTF-8') + options.addStringOption('charset', 'UTF-8') +} + +artifacts { + archives androidSourcesJar + archives androidJavadocsJar +} + +afterEvaluate { project -> + android.libraryVariants.all { variant -> + tasks.androidJavadocs.doFirst { + classpath += files(variant.javaCompile.classpath.files) + } + } +} + diff --git a/platform/android/gradle/gradle-publish.gradle b/platform/android/gradle/gradle-publish.gradle deleted file mode 100644 index a3bf83348f..0000000000 --- a/platform/android/gradle/gradle-publish.gradle +++ /dev/null @@ -1,143 +0,0 @@ -apply plugin: 'maven' -apply plugin: 'signing' - -allprojects { - group project.GROUP - version project.VERSION_NAME - - repositories { - mavenCentral() - } -} - -repositories { - mavenCentral() -} - -def isReleaseBuild() { - return VERSION_NAME.contains("SNAPSHOT") == false -} - -def isLocalBuild() { - if (System.getenv('IS_LOCAL_DEVELOPMENT') != null) { - return System.getenv('IS_LOCAL_DEVELOPMENT').toBoolean() - } - return true -} - -def getReleaseRepositoryUrl() { - return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL : - "https://oss.sonatype.org/service/local/staging/deploy/maven2/" -} - -def getSnapshotRepositoryUrl() { - return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL : - "https://oss.sonatype.org/content/repositories/snapshots/" -} - -def obtainMavenLocalUrl() { - return getRepositories().mavenLocal().getUrl() -} - -def getRepositoryUsername() { - return hasProperty('USERNAME') ? USERNAME : - (hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "") -} - -def getRepositoryPassword() { - return hasProperty('PASSWORD') ? PASSWORD : - (hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "") -} - -afterEvaluate { project -> - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME - - if (isLocalBuild()) { - repository(url: obtainMavenLocalUrl()) - } else { - repository(url: getReleaseRepositoryUrl()) { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } - snapshotRepository(url: getSnapshotRepositoryUrl()) { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } - } - - pom.project { - name POM_NAME - packaging POM_PACKAGING - description POM_DESCRIPTION - url POM_URL - - scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEV_CONNECTION - } - - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST - } - } - - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME - } - } - } - } - } - } - - signing { - required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } - sign configurations.archives - } - - task androidJavadocs(type: Javadoc) { - source = android.sourceSets.main.java.sourceFiles - classpath = files(android.bootClasspath) - } - - task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { - classifier = 'javadoc' - from androidJavadocs.destinationDir - } - - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.sourceFiles - } - - tasks.withType(Javadoc) { - options.addStringOption('encoding', 'UTF-8') - options.addStringOption('docencoding', 'UTF-8') - options.addStringOption('charset', 'UTF-8') - } - - artifacts { - archives androidSourcesJar - archives androidJavadocsJar - } -} - -// See: https://github.com/chrisbanes/gradle-mvn-push/issues/43#issuecomment-84140513 -afterEvaluate { project -> - android.libraryVariants.all { variant -> - tasks.androidJavadocs.doFirst { - classpath += files(variant.javaCompile.classpath.files) - } - } -} |