From dd4351bc72e66053a325843a9fbb511a506d24fb Mon Sep 17 00:00:00 2001 From: Arnaud Roland Date: Fri, 5 Jul 2024 10:14:18 +0200 Subject: [PATCH] all: update maven-publish --- hms-plugin/build.gradle | 8 ++++- hms-plugin/maven-publish.gradle | 62 +++------------------------------ 2 files changed, 12 insertions(+), 58 deletions(-) diff --git a/hms-plugin/build.gradle b/hms-plugin/build.gradle index 43d9e3d..0caa555 100644 --- a/hms-plugin/build.gradle +++ b/hms-plugin/build.gradle @@ -42,10 +42,16 @@ android { } } } + publishing { + singleVariant("release") { + withSourcesJar() + withJavadocJar() + } + } } dependencies { - api 'com.batch.android:batch-sdk:2.0+' + api 'com.batch.android:batch-sdk:2.0.3' api 'com.huawei.hms:push:6.5.0.300' implementation "androidx.annotation:annotation:$androidXLibraryVersion" diff --git a/hms-plugin/maven-publish.gradle b/hms-plugin/maven-publish.gradle index e851597..77ccc03 100644 --- a/hms-plugin/maven-publish.gradle +++ b/hms-plugin/maven-publish.gradle @@ -18,38 +18,17 @@ if (signingFile.exists()) { } } -task androidJavadocs(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - android.libraryVariants.all { variant -> - if (variant.name == 'release') { - owner.classpath += variant.getCompileClasspath() - } - } - exclude '**/R.html', '**/R.*.html', '**/index.html' -} - -task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { - archiveClassifier.set("javadoc") - from androidJavadocs.destinationDir -} - -task androidSourcesJar(type: Jar) { - archiveClassifier.set("sources") - from android.sourceSets.main.java.srcDirs -} - publishing { publications { - HMSSDK(MavenPublication) { + release(MavenPublication) { groupId mavenGroupId artifactId mavenArtifact version android.defaultConfig.versionName - artifact "$buildDir/outputs/aar/hms-plugin-release.aar" - artifact androidJavadocsJar - artifact androidSourcesJar + afterEvaluate { + from components.release + } pom { name = "Batch.com Android HMS SDK" @@ -88,37 +67,6 @@ publishing { url = "https://batch.com" } } - - pom.withXml { - final dependenciesNode = asNode().appendNode('dependencies') - ext.addDependency = { Dependency dep, String scope -> - if (dep.group == null || dep.version == null || dep.name == null || dep.name == "unspecified") - return // ignore invalid dependencies - - final dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', dep.group) - dependencyNode.appendNode('artifactId', dep.name) - dependencyNode.appendNode('version', dep.version) - dependencyNode.appendNode('scope', scope) - - if (!dep.transitive) { - // If this dependency is transitive, we should force exclude all its dependencies them from the POM - final exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion') - exclusionNode.appendNode('groupId', '*') - exclusionNode.appendNode('artifactId', '*') - } else if (!dep.properties.excludeRules.empty) { - // Otherwise add specified exclude rules - final exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion') - dep.properties.excludeRules.each { ExcludeRule rule -> - exclusionNode.appendNode('groupId', rule.group ?: '*') - exclusionNode.appendNode('artifactId', rule.module ?: '*') - } - } - } - - configurations.api.getDependencies().each { dep -> addDependency(dep, "compile") } - configurations.implementation.getDependencies().each { dep -> addDependency(dep, "runtime") } - } } } @@ -140,7 +88,7 @@ publishing { } signing { - sign publishing.publications.HMSSDK + sign publishing.publications.release } // Do not sign if we run the publishToMavenLocal task, useful for dev