Skip to content

Commit

Permalink
fix(cd): use gradle convention plugin rather than subproject to apply…
Browse files Browse the repository at this point in the history
… maven publishing configuration

That way we can explicitly use "public-lib" gradle plugin on modules that need to be published
  • Loading branch information
lilgallon committed Jul 22, 2024
1 parent 0e681d1 commit 30a04a7
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 49 deletions.
49 changes: 0 additions & 49 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
import java.util.Base64

buildscript {
dependencies {
Expand All @@ -20,7 +19,6 @@ val versionNumber = System.getenv("VERSION")?.substringAfter("R-") ?: "0.0.15"
println("building current version: $versionNumber")

allprojects {

group = "com.izivia"
version = versionNumber

Expand All @@ -47,8 +45,6 @@ subprojects {
apply {
plugin("java")
plugin("org.jetbrains.kotlin.jvm")
plugin("maven-publish")
plugin("signing")
plugin("org.jlleitschuh.gradle.ktlint")
}

Expand All @@ -63,51 +59,6 @@ subprojects {
exclude { element -> element.file.path.contains("generated") }
}
}

extensions.getByType<PublishingExtension>().publications {
create<MavenPublication>("maven") {
pom {
url.set("https://github.com/IZIVIA/ocpi-toolkit")

scm {
connection.set("scm:git:https://github.com/IZIVIA/ocpi-toolkit.git")
developerConnection.set("scm:git:[email protected]:IZIVIA/ocpi-toolkit.git")
url.set("https://github.com/IZIVIA/ocpi-toolkit")
}

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}

developers {
developer {
id.set("IZIVIA")
name.set("IZIVIA")
email.set("[email protected]")
url.set("https://www.izivia.com/")
organization.set("IZIVIA")
organizationUrl.set("https://www.izivia.com/")
}
}
}
}
}

extensions.getByType<SigningExtension>()
.sign(extensions.getByType<PublishingExtension>().publications.named("maven").get())
if (System.getenv("GPG_PRIVATE_KEY") != null) {
extensions.getByType<SigningExtension>().useInMemoryPgpKeys(
Base64.getDecoder().decode(System.getenv("GPG_PRIVATE_KEY")).decodeToString(),
System.getenv("GPG_PASSPHRASE")
)
}

tasks.withType<Sign> {
onlyIf { System.getenv("GPG_PRIVATE_KEY") != null }
}
}

nexusPublishing {
Expand Down
56 changes: 56 additions & 0 deletions buildSrc/src/main/kotlin/public-lib.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.Sign
import org.gradle.plugins.signing.SigningExtension
import java.util.*

plugins {
id("maven-publish")
id("signing")
}

extensions.getByType<PublishingExtension>().publications {
create<MavenPublication>("maven") {
pom {
url.set("https://github.com/IZIVIA/ocpi-toolkit")

scm {
connection.set("scm:git:https://github.com/IZIVIA/ocpi-toolkit.git")
developerConnection.set("scm:git:[email protected]:IZIVIA/ocpi-toolkit.git")
url.set("https://github.com/IZIVIA/ocpi-toolkit")
}

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}

developers {
developer {
id.set("IZIVIA")
name.set("IZIVIA")
email.set("[email protected]")
url.set("https://www.izivia.com/")
organization.set("IZIVIA")
organizationUrl.set("https://www.izivia.com/")
}
}
}
}
}

extensions.getByType<SigningExtension>()
.sign(extensions.getByType<PublishingExtension>().publications.named("maven").get())
if (System.getenv("GPG_PRIVATE_KEY") != null) {
extensions.getByType<SigningExtension>().useInMemoryPgpKeys(
Base64.getDecoder().decode(System.getenv("GPG_PRIVATE_KEY")).decodeToString(),
System.getenv("GPG_PASSPHRASE")
)
}

tasks.withType<Sign> {
onlyIf { System.getenv("GPG_PRIVATE_KEY") != null }
}
1 change: 1 addition & 0 deletions ocpi-toolkit-2.2.1/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("java-library")
id("com.google.devtools.ksp")
`public-lib`
}

dependencies {
Expand Down
4 changes: 4 additions & 0 deletions transport/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
`public-lib`
}

java {
withJavadocJar()
withSourcesJar()
Expand Down

0 comments on commit 30a04a7

Please sign in to comment.