-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.8.0: test extensions, no more arrow deps
- Loading branch information
1 parent
2652065
commit 4990844
Showing
14 changed files
with
323 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
import io.gitlab.arturbosch.detekt.Detekt | ||
import org.gradle.kotlin.dsl.support.listFilesOrdered | ||
import java.lang.management.ManagementFactory | ||
import java.net.URI | ||
|
||
plugins { | ||
kotlin("multiplatform") | ||
id("maven-publish") | ||
id("signing") | ||
id("org.jetbrains.dokka") | ||
id("org.jetbrains.kotlinx.kover") version "0.8.0" | ||
id("io.gitlab.arturbosch.detekt") version "1.23.6" | ||
} | ||
|
||
val artifactVersion: String by extra | ||
group = "at.asitplus" | ||
version = artifactVersion | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
val dokkaOutputDir = "$projectDir/docs" | ||
dokka { | ||
dokkaSourceSets { | ||
|
||
named("commonMain") { | ||
sourceLink { | ||
val path = "${projectDir}/src/$name/kotlin" | ||
println(path) | ||
localDirectory.set(file(path)) | ||
remoteUrl.set( | ||
URI("https://github.com/a-sit-plus/kmmresult/tree/main/src/$name/kotlin") | ||
) | ||
// Suffix which is used to append the line number to the URL. Use #L for GitHub | ||
remoteLineSuffix.set("#L") | ||
} | ||
} | ||
} | ||
pluginsConfiguration.html { | ||
footerMessage = "© 2024 A-SIT Plus GmbH" | ||
} | ||
} | ||
val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") { | ||
delete(dokkaOutputDir) | ||
} | ||
val javadocJar = tasks.register<Jar>("javadocJar") { | ||
dependsOn(deleteDokkaOutputDir, tasks.dokkaGenerate) | ||
archiveClassifier.set("javadoc") | ||
from(dokkaOutputDir) | ||
} | ||
|
||
tasks.getByName("check") { | ||
dependsOn("detektMetadataMain") | ||
} | ||
|
||
|
||
//first sign everything, then publish! | ||
tasks.withType<AbstractPublishToMaven>() { | ||
tasks.withType<Sign>().forEach { | ||
dependsOn(it) | ||
} | ||
} | ||
|
||
kotlin { | ||
|
||
macosArm64() | ||
macosX64() | ||
tvosArm64() | ||
tvosX64() | ||
tvosSimulatorArm64() | ||
iosX64() | ||
iosArm64() | ||
iosSimulatorArm64() | ||
|
||
|
||
jvmToolchain(11) | ||
jvm { | ||
compilations.all { | ||
kotlinOptions { | ||
freeCompilerArgs = listOf( | ||
"-Xjsr305=strict" | ||
) | ||
} | ||
} | ||
withJava() //for Java Interop tests | ||
} | ||
|
||
js(IR) { | ||
browser { testTask { enabled = false } } | ||
nodejs() | ||
} | ||
linuxX64() | ||
linuxArm64() | ||
mingwX64() | ||
|
||
sourceSets { | ||
commonMain.dependencies { | ||
implementation(project(":kmmresult")) | ||
api("io.kotest:kotest-assertions-core:5.9.1") | ||
} | ||
} | ||
|
||
tasks.withType<Detekt>().configureEach { | ||
reports { | ||
xml.required.set(true) | ||
html.required.set(false) | ||
txt.required.set(false) | ||
sarif.required.set(true) | ||
md.required.set(true) | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
dependencies { | ||
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.6") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
publishing { | ||
publications { | ||
withType<MavenPublication> { | ||
artifact(javadocJar) | ||
pom { | ||
name.set("KmmResult Test") | ||
description.set("Kotest helperrs for KmmResult") | ||
url.set("https://github.com/a-sit-plus/kmmresult") | ||
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("JesusMcCloud") | ||
name.set("Bernd Prünster") | ||
email.set("[email protected]") | ||
} | ||
developer { | ||
id.set("nodh") | ||
name.set("Christian Kollmann") | ||
email.set("[email protected]") | ||
} | ||
} | ||
scm { | ||
connection.set("scm:git:[email protected]:a-sit-plus/kmmresult.git") | ||
developerConnection.set("scm:git:[email protected]:a-sit-plus/kmmresult.git") | ||
url.set("https://github.com/a-sit-plus/kmmresult") | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
mavenLocal() { | ||
signing.isRequired = false | ||
} | ||
} | ||
} | ||
|
||
|
||
signing { | ||
val signingKeyId: String? by project | ||
val signingKey: String? by project | ||
val signingPassword: String? by project | ||
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) | ||
sign(publishing.publications) | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
kmmresult-test/src/commonMain/kotlin/at/asitplus/TestExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2021 - 2023 A-SIT Plus GmbH. Obviously inspired and partially copy-pasted from kotlin.Result. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. | ||
*/ | ||
package at.asitplus | ||
|
||
import io.kotest.matchers.Matcher | ||
import io.kotest.matchers.MatcherResult | ||
import io.kotest.matchers.shouldBe | ||
|
||
/** | ||
* Shorthand for `getOrThrow() shouldBe expected` | ||
*/ | ||
infix fun <T> KmmResult<T>.shouldSucceedWith(expected: T): T = getOrThrow() shouldBe expected | ||
|
||
/** | ||
* [KmmResult] matcher. Use as follows: `okResult should succeed`, `errResult shouldNot succeed` | ||
*/ | ||
@Suppress("ClassNaming") | ||
object succeed : Matcher<KmmResult<*>> { | ||
override fun test(value: KmmResult<*>) = | ||
MatcherResult( | ||
value.isSuccess, | ||
failureMessageFn = { | ||
"Should have succeeded, but failed:\n${ | ||
value.exceptionOrNull()!!.stackTraceToString() | ||
}" | ||
}, | ||
negatedFailureMessageFn = { "Should have failed, but succeeded with ${value.getOrNull()!!}" } | ||
) | ||
} |
Oops, something went wrong.