Skip to content

Commit

Permalink
Extract shared build logic to convention plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbull committed Mar 3, 2024
1 parent bae2d88 commit 88e31cd
Show file tree
Hide file tree
Showing 14 changed files with 302 additions and 337 deletions.
13 changes: 1 addition & 12 deletions benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
description = "Benchmarks for kotlin-result."

plugins {
kotlin("multiplatform")
id("org.jetbrains.kotlinx.benchmark")
id("org.jetbrains.kotlin.plugin.allopen")
id("kotlin-conventions")
}

allOpen {
Expand All @@ -19,15 +17,6 @@ benchmark {
}

kotlin {
jvmToolchain(8)

jvm {
}

js(IR) {
nodejs()
}

sourceSets {
val commonMain by getting {
dependencies {
Expand Down
1 change: 1 addition & 0 deletions benchmarks/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
description=Benchmarks for kotlin-result.
249 changes: 0 additions & 249 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.github.benmanes.gradle.versions.updates.gradle.GradleReleaseChannel
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper

val ossrhUsername: String? by project
val ossrhPassword: String? by project

val signingKeyId: String? by project // must be the last 8 digits of the key
val signingKey: String? by project
val signingPassword: String? by project

description = "A Result monad for modelling success or failure operations."

plugins {
base
alias(libs.plugins.versions)

alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.benchmark) apply false
alias(libs.plugins.kotlin.allopen) apply false
alias(libs.plugins.dokka) apply false
}

tasks.withType<DependencyUpdatesTask> {
Expand All @@ -32,237 +17,3 @@ tasks.withType<DependencyUpdatesTask> {
}
}
}

subprojects {
plugins.withType<MavenPublishPlugin> {
apply(plugin = "org.gradle.signing")

plugins.withType<KotlinMultiplatformPluginWrapper> {
apply(plugin = "org.jetbrains.dokka")

val dokkaHtml by tasks.existing(DokkaTask::class)

val javadocJar by tasks.registering(Jar::class) {
group = LifecycleBasePlugin.BUILD_GROUP
description = "Assembles a jar archive containing the Javadoc API documentation."
archiveClassifier.set("javadoc")
from(dokkaHtml)
}

tasks.withType<Jar> {
from(rootDir.resolve("LICENSE")) {
into("META-INF")
}
}

configure<KotlinMultiplatformExtension> {
explicitApi()

jvmToolchain(8)

jvm {
mavenPublication {
artifact(javadocJar.get())
}
}

js(IR) {
browser()
nodejs()
}

linuxX64()

mingwX64()

macosArm64()
macosX64()

iosArm64()
iosSimulatorArm64()
iosX64()

tvosArm64()
tvosSimulatorArm64()
tvosX64()

watchosArm32()
watchosArm64()
watchosSimulatorArm64()
watchosX64()
}
}

configure<PublishingExtension> {
repositories {
maven {
if (project.version.toString().endsWith("SNAPSHOT")) {
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
} else {
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2")
}

credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}

publications.withType<MavenPublication> {
pom {
name.set(project.name)
url.set("https://github.com/michaelbull/kotlin-result")
inceptionYear.set("2017")

licenses {
license {
name.set("ISC License")
url.set("https://opensource.org/licenses/isc-license.txt")
}
}

developers {
developer {
name.set("Michael Bull")
url.set("https://www.michael-bull.com")
}
}

contributors {
contributor {
name.set("Kevin Herron")
url.set("https://github.com/kevinherron")
}

contributor {
name.set("Markus Padourek")
url.set("https://github.com/Globegitter")
}

contributor {
name.set("Tristan Hamilton")
url.set("https://github.com/Munzey")
}

contributor {
name.set("Joseph Van der Wee")
url.set("https://github.com/jvanderwee")
}

contributor {
name.set("Gregory Inouye")
url.set("https://github.com/gregoryinouye")
}

contributor {
name.set("Thomas Oddsund")
url.set("https://github.com/oddsund")
}

contributor {
name.set("Jan Müller")
url.set("https://github.com/DerYeger")
}

contributor {
name.set("avently")
url.set("https://github.com/avently")
}

contributor {
name.set("gsteckman")
url.set("https://github.com/gsteckman")
}

contributor {
name.set("Mathias Guelton")
url.set("https://github.com/mguelton")
}

contributor {
name.set("Jordan Bergin")
url.set("https://github.com/MrBergin")
}

contributor {
name.set("Pablo Gonzalez Alonso")
url.set("https://pablisco.com/")
}

contributor {
name.set("Joseph Cooper")
url.set("https://grodin.github.io/")
}

contributor {
name.set("Sebastian Kappen")
url.set("https://github.com/Nimelrian")
}

contributor {
name.set("Dmitry Suzdalev")
url.set("https://github.com/dimsuz")
}

contributor {
name.set("Berik Visschers")
url.set("https://visschers.nu/")
}

contributor {
name.set("Matthew Nelson")
url.set("https://matthewnelson.io/")
}

contributor {
name.set("Matthias Geisler")
url.set("https://github.com/bitPogo")
}

contributor {
name.set("Kirill Zhukov")
url.set("https://github.com/kirillzh")
}

contributor {
name.set("Peter Cunderlik")
url.set("https://github.com/peter-cunderlik-kmed")
}

contributor {
name.set("YuitoSato")
url.set("https://github.com/YuitoSato")
}

contributor {
name.set("Dmitry Bock")
url.set("https://github.com/Jhabkin")
}
}

scm {
connection.set("scm:git:https://github.com/michaelbull/kotlin-result")
developerConnection.set("scm:git:git@github.com:michaelbull/kotlin-result.git")
url.set("https://github.com/michaelbull/kotlin-result")
}

issueManagement {
system.set("GitHub")
url.set("https://github.com/michaelbull/kotlin-result/issues")
}

ciManagement {
system.set("GitHub")
url.set("https://github.com/michaelbull/kotlin-result/actions?query=workflow%3Aci")
}
}
}

configure<SigningExtension> {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publications)
}
}
}
}
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

dependencies {
implementation(libs.kotlin.gradle.plugin)
}
19 changes: 19 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}

versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
66 changes: 66 additions & 0 deletions buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
plugins {
kotlin("multiplatform")
}

kotlin {
jvmToolchain(8)

jvm()

js(IR) {
browser()
nodejs()
}

linuxX64()

mingwX64()

macosArm64()
macosX64()

iosArm64()
iosSimulatorArm64()
iosX64()

tvosArm64()
tvosSimulatorArm64()
tvosX64()

watchosArm32()
watchosArm64()
watchosSimulatorArm64()
watchosX64()

sourceSets {
all {
languageSettings.apply {
optIn("kotlin.contracts.ExperimentalContracts")
}
}

commonTest {
dependencies {
implementation(kotlin("test"))
}
}

jvmTest {
dependencies {
implementation(kotlin("test-junit"))
}
}

jsTest {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}

tasks.withType<Jar> {
from(rootDir.resolve("LICENSE")) {
into("META-INF")
}
}
Loading

0 comments on commit 88e31cd

Please sign in to comment.