Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Move to using the Maven Publish DSL #2815

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ fun Project.configureAndroid() {
)
)
}

publishing {
singleVariant("release") {
withSourcesJar()
}
}
}

dependencies {
Expand Down
36 changes: 13 additions & 23 deletions configuration/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,14 @@ def getRepositoryPassword() {
}

afterEvaluate { project ->
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.source
}


publishing {
publications {
library(MavenPublication) {
groupId POM_GROUP
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
Expand Down Expand Up @@ -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')) }
}
}
}
Expand All @@ -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
}
}