Skip to content

Commit

Permalink
🔧 Rework publishing configuration to follow recommended schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxr1998 committed Sep 6, 2023
1 parent b566d90 commit 568847d
Showing 1 changed file with 49 additions and 50 deletions.
99 changes: 49 additions & 50 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

dependencies {
Expand Down Expand Up @@ -94,11 +100,6 @@ tasks {
}
}

val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(android.sourceSets.getByName("main").java.srcDirs)
}

var ossrhUsername: String? = null
var ossrhPassword: String? = null
var githubToken: String? = null
Expand All @@ -113,60 +114,58 @@ if (propFile.exists()) {
}

// Maven publishing config
publishing {
publications {
register<MavenPublication>("production") {
groupId = libraryGroup
artifactId = libraryName
version = libraryVersion

afterEvaluate {
from(components["release"])
}
afterEvaluate {
publishing {
publications {
register<MavenPublication>("production") {
groupId = libraryGroup
artifactId = libraryName
version = libraryVersion

artifact(sourcesJar.get())
from(components["release"])

pom {
name.set(prettyLibraryName)
description.set("Android Preferences defined through Kotlin DSL, shown in a RecyclerView")
url.set("https://github.com/Maxr1998/ModernAndroidPreferences")
pom {
name.set(prettyLibraryName)
description.set("Android Preferences defined through Kotlin DSL, shown in a RecyclerView")
url.set("https://github.com/Maxr1998/ModernAndroidPreferences")

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
developers {
developer {
id.set("Maxr1998")
name.set("Max Rumpf")
url.set("https://github.com/Maxr1998")
developers {
developer {
id.set("Maxr1998")
name.set("Max Rumpf")
url.set("https://github.com/Maxr1998")
}
}
scm {
connection.set("scm:git:github.com/Maxr1998/ModernAndroidPreferences.git")
developerConnection.set("scm:git:ssh://github.com/Maxr1998/ModernAndroidPreferences.git")
url.set("https://github.com/Maxr1998/ModernAndroidPreferences/tree/master")
}
}
scm {
connection.set("scm:git:github.com/Maxr1998/ModernAndroidPreferences.git")
developerConnection.set("scm:git:ssh://github.com/Maxr1998/ModernAndroidPreferences.git")
url.set("https://github.com/Maxr1998/ModernAndroidPreferences/tree/master")
}
}
}
}
repositories {
maven {
name = "sonatype"
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = ossrhUsername
password = ossrhPassword
repositories {
maven {
name = "sonatype"
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
maven {
name = "GitHubPackages"
setUrl("https://maven.pkg.github.com/Maxr1998/ModernAndroidPreferences")
credentials {
username = "Maxr1998"
password = githubToken
maven {
name = "GitHubPackages"
setUrl("https://maven.pkg.github.com/Maxr1998/ModernAndroidPreferences")
credentials {
username = "Maxr1998"
password = githubToken
}
}
}
}
Expand Down

0 comments on commit 568847d

Please sign in to comment.