From d4b3711931a1102c1793376391ccbff178ba1452 Mon Sep 17 00:00:00 2001 From: Matt Creaser Date: Fri, 10 May 2024 14:22:24 -0300 Subject: [PATCH] Move to using the Maven Publish Plugin --- build.gradle.kts | 6 ++++++ configuration/publishing.gradle | 36 ++++++++++++--------------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b474f780e4..5bb4bfc63c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -180,6 +180,12 @@ fun Project.configureAndroid() { ) ) } + + publishing { + singleVariant("release") { + withSourcesJar() + } + } } dependencies { diff --git a/configuration/publishing.gradle b/configuration/publishing.gradle index fdf2cbf547..3df3916145 100644 --- a/configuration/publishing.gradle +++ b/configuration/publishing.gradle @@ -42,12 +42,6 @@ def getRepositoryPassword() { } afterEvaluate { project -> - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.source - } - - publishing { publications { library(MavenPublication) { @@ -55,13 +49,7 @@ afterEvaluate { project -> artifactId POM_ARTIFACT_ID version VERSION_NAME - artifact("${buildDir}/outputs/aar/${artifactId}-release.aar") - if (project.getPlugins().hasPlugin('com.android.application') || - project.getPlugins().hasPlugin('com.android.library')) { - artifact(androidSourcesJar) - } else { - artifact(sourcesJar) - } + from(components.named("release").get()) pom { name = POM_NAME @@ -92,16 +80,12 @@ afterEvaluate { project -> } withXml { - def dependenciesNode = asNode().appendNode('dependencies') - // Note that this only handles implementation - // dependencies. In the future, may need to add api, - // etc. - configurations.implementation.allDependencies.each { - def dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', it.group) - dependencyNode.appendNode('artifactId', it.name) - dependencyNode.appendNode('version', it.version) - } + // Remove the scope information for all dependencies. This puts + // everything at "compile" scope, which matches the way Amplify V2 has been + // published historically. For v3 we should remove this and include the + // scope information for our dependencies. + def dependencies = asNode().get('dependencies').first() + dependencies.each { it.remove(it.get('scope')) } } } } @@ -128,4 +112,10 @@ afterEvaluate { project -> } sign publishing.publications.library } + + // Turn off Gradle metadata. This is to maintain compatibility with the way Amplify V2 has + // been published historically. For v3 we should remove this and publish the gradle metadata. + tasks.withType(GenerateModuleMetadata).configureEach { + enabled = false + } }