Skip to content

Commit

Permalink
all: update maven-publish
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-roland committed Jul 5, 2024
1 parent 068f10a commit dd4351b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 58 deletions.
8 changes: 7 additions & 1 deletion hms-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
62 changes: 5 additions & 57 deletions hms-plugin/maven-publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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") }
}
}
}

Expand All @@ -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
Expand Down

0 comments on commit dd4351b

Please sign in to comment.