diff --git a/build.gradle.kts b/build.gradle.kts index b474f780e..5bb4bfc63 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 fdf2cbf54..3df391614 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 + } }