diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts index 228941b..97a9364 100644 --- a/benchmarks/build.gradle.kts +++ b/benchmarks/build.gradle.kts @@ -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 { @@ -19,15 +17,6 @@ benchmark { } kotlin { - jvmToolchain(8) - - jvm { - } - - js(IR) { - nodejs() - } - sourceSets { val commonMain by getting { dependencies { diff --git a/benchmarks/gradle.properties b/benchmarks/gradle.properties new file mode 100644 index 0000000..554e00b --- /dev/null +++ b/benchmarks/gradle.properties @@ -0,0 +1 @@ +description=Benchmarks for kotlin-result. diff --git a/build.gradle.kts b/build.gradle.kts index ef7e0ee..5ad72e1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 { @@ -32,237 +17,3 @@ tasks.withType { } } } - -subprojects { - plugins.withType { - apply(plugin = "org.gradle.signing") - - plugins.withType { - 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 { - from(rootDir.resolve("LICENSE")) { - into("META-INF") - } - } - - configure { - 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 { - 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 { - 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 { - useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) - sign(publications) - } - } - } -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..75c0eb2 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` +} + +dependencies { + implementation(libs.kotlin.gradle.plugin) +} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..17f9791 --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,19 @@ +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } + + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} diff --git a/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts new file mode 100644 index 0000000..4b223f8 --- /dev/null +++ b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts @@ -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 { + from(rootDir.resolve("LICENSE")) { + into("META-INF") + } +} diff --git a/buildSrc/src/main/kotlin/publish-conventions.gradle.kts b/buildSrc/src/main/kotlin/publish-conventions.gradle.kts new file mode 100644 index 0000000..2b7e842 --- /dev/null +++ b/buildSrc/src/main/kotlin/publish-conventions.gradle.kts @@ -0,0 +1,196 @@ +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.api.tasks.bundling.Jar +import org.gradle.kotlin.dsl.`maven-publish` + +plugins { + `maven-publish` + signing +} + +publishing { + 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 { + val ossrhUsername: String? by project + val ossrhPassword: String? by project + + username = ossrhUsername + password = ossrhPassword + } + } + } + + publications.withType { + val targetName = this@withType.name + + artifact(tasks.register("${targetName}JavadocJar", Jar::class) { + group = LifecycleBasePlugin.BUILD_GROUP + description = "Assembles a jar archive containing the Javadoc API documentation of target '$targetName'." + archiveClassifier.set("javadoc") + archiveAppendix.set(targetName) + }) + + pom { + name.set(project.name) + description.set(project.description) + 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") + } + } + } +} + +signing { + val signingKeyId: String? by project // must be the last 8 digits of the key + val signingKey: String? by project + val signingPassword: String? by project + + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) + sign(publishing.publications) +} diff --git a/example/build.gradle.kts b/example/build.gradle.kts index 9cce8bd..ec0749b 100644 --- a/example/build.gradle.kts +++ b/example/build.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - plugins { application kotlin("jvm") diff --git a/gradle.properties b/gradle.properties index fe15cea..d39b270 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,6 @@ group=com.michael-bull.kotlin-result version=1.1.19-SNAPSHOT +description=A multiplatform Result monad for modelling success or failure operations. kotlin.code.style=official kotlin.native.ignoreDisabledTargets=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8ab0b6b..eadf7b7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,15 +1,15 @@ [versions] -dokka = "1.9.10" kotlin = "1.9.22" kotlin-benchmark = "0.4.10" kotlin-coroutines = "1.8.0" ktor = "2.3.8" -logback = "1.5.1" +logback = "1.3.14" versions-plugin = "0.51.0" [libraries] logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } kotlin-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlin-benchmark" } kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" } @@ -21,7 +21,6 @@ ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negoti ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" } [plugins] -dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } kotlin-allopen = { id = "org.jetbrains.kotlin.plugin.allopen", version.ref = "kotlin" } kotlin-benchmark = { id = "org.jetbrains.kotlinx.benchmark", version.ref = "kotlin-benchmark" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } diff --git a/kotlin-result-coroutines/build.gradle.kts b/kotlin-result-coroutines/build.gradle.kts index 934ee18..ea326f3 100644 --- a/kotlin-result-coroutines/build.gradle.kts +++ b/kotlin-result-coroutines/build.gradle.kts @@ -1,18 +1,13 @@ -description = "Extensions for using kotlin-result with kotlinx-coroutines." - plugins { `maven-publish` - kotlin("multiplatform") + id("kotlin-conventions") + id("publish-conventions") } kotlin { - sourceSets { - all { - languageSettings.apply { - optIn("kotlin.contracts.ExperimentalContracts") - } - } + explicitApi() + sourceSets { commonMain { dependencies { implementation(libs.kotlin.coroutines.core) @@ -22,31 +17,8 @@ kotlin { commonTest { dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) implementation(libs.kotlin.coroutines.test) } } - - jvmTest { - dependencies { - implementation(kotlin("test-junit")) - implementation(kotlin("test")) - } - } - - jsTest { - dependencies { - implementation(kotlin("test-js")) - } - } - } -} - -publishing { - publications.withType { - pom { - description.set(project.description) - } } } diff --git a/kotlin-result-coroutines/gradle.properties b/kotlin-result-coroutines/gradle.properties new file mode 100644 index 0000000..269e073 --- /dev/null +++ b/kotlin-result-coroutines/gradle.properties @@ -0,0 +1 @@ +description=Extensions for using kotlin-result with kotlinx-coroutines. diff --git a/kotlin-result/build.gradle.kts b/kotlin-result/build.gradle.kts index 5821834..98e56ea 100644 --- a/kotlin-result/build.gradle.kts +++ b/kotlin-result/build.gradle.kts @@ -1,15 +1,14 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask -description = "A Result monad for modelling success or failure operations." - plugins { `maven-publish` - kotlin("multiplatform") + id("kotlin-conventions") + id("publish-conventions") } kotlin { - jvmToolchain(8) + explicitApi() // Additional targets not currently supported by coroutines androidNativeArm32() @@ -24,40 +23,6 @@ kotlin { binaries.executable() nodejs() } - - 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")) - } - } - } -} - -publishing { - publications.withType { - pom { - description.set(project.description) - } - } } /* https://youtrack.jetbrains.com/issue/KT-63014/Running-tests-with-wasmJs-in-1.9.20-requires-Chrome-Canary#focus=Comments-27-8321383.0-0 */ diff --git a/settings.gradle.kts b/settings.gradle.kts index dc2a5bc..c5d6c4a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -6,7 +6,7 @@ pluginManagement { } plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0" + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" } dependencyResolutionManagement {