I am using the maven-publish and signing Gradle plugins in my Android library's Groovy DSL build.gradle
file as follows:
plugins {
id("maven-publish")
id("signing")
}
android {
publishing {
singleVariant("release") {
withJavadocJar()
withSourcesJar()
}
}
}
publishing {
publications {
release(MavenPublication) {
afterEvaluate {
from components.release
}
groupId getProperty("groupId")
artifactId getProperty("artifactId")
version getProperty("version")
}
}
repositories {
maven {
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username getProperty("sonatypeUsername")
password getProperty("sonatypePassword")
}
}
}
}
signing {
sign publishing.publications.release
}
I have omitted the parts of my build.gradle
file which are unrelated to or optional for publishing and signing.
How do I convert these declarations to the Kotlin DSL?
Here are the declarations converted to the Kotlin DSL:
plugins {
`maven-publish`
signing
}
android {
publishing {
singleVariant("release") {
withJavadocJar()
withSourcesJar()
}
}
}
publishing {
publications {
create<MavenPublication>("release") {
afterEvaluate {
from(components["release"])
}
groupId = properties["groupId"].toString()
artifactId = properties["artifactId"].toString()
version = properties["version"].toString()
}
}
repositories {
maven {
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = properties["sonatypeUsername"].toString()
password = properties["sonatypePassword"].toString()
}
}
}
}
signing {
sign(publishing.publications["release"])
}
build.gradle.kts
file which includes all of the declarations above here.