Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module to wrap kotlin objects for validation #197

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
kotlin.code.style=official
kotlin.js.compiler=ir
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx1536M
org.gradle.java.installations.auto-download=false
org.gradle.daemon=false

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public final class io/github/optimumcode/json/schema/wrappers/objects/ObjectWrappers {
public static final fun wrapAsElement (Ljava/lang/Object;)Lio/github/optimumcode/json/schema/model/AbstractElement;
public static final fun wrapAsElement (Ljava/lang/Object;Lio/github/optimumcode/json/schema/wrappers/objects/WrappingConfiguration;)Lio/github/optimumcode/json/schema/model/AbstractElement;
public static synthetic fun wrapAsElement$default (Ljava/lang/Object;Lio/github/optimumcode/json/schema/wrappers/objects/WrappingConfiguration;ILjava/lang/Object;)Lio/github/optimumcode/json/schema/model/AbstractElement;
public static final fun wrappingConfiguration ()Lio/github/optimumcode/json/schema/wrappers/objects/WrappingConfiguration;
public static final fun wrappingConfiguration (Z)Lio/github/optimumcode/json/schema/wrappers/objects/WrappingConfiguration;
public static final fun wrappingConfiguration (ZZ)Lio/github/optimumcode/json/schema/wrappers/objects/WrappingConfiguration;
public static synthetic fun wrappingConfiguration$default (ZZILjava/lang/Object;)Lio/github/optimumcode/json/schema/wrappers/objects/WrappingConfiguration;
}

public final class io/github/optimumcode/json/schema/wrappers/objects/WrappingConfiguration {
public fun <init> ()V
public final fun getAllowSets ()Z
public final fun getCharAsCodepoint ()Z
}

150 changes: 150 additions & 0 deletions json-schema-validator-objects/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
@file:OptIn(ExperimentalWasmDsl::class)

import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTests
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType

plugins {
alias(libs.plugins.kotlin.mutliplatform)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotest.multiplatform)
alias(libs.plugins.kover)
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)
alias(libs.plugins.kotlin.dokka)
convention.publication
}

kotlin {
explicitApi()

@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
freeCompilerArgs.add("-opt-in=io.github.optimumcode.json.schema.ExperimentalApi")
}
jvmToolchain(11)
jvm {
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
js(IR) {
browser()
generateTypeScriptDefinitions()
nodejs()
}
wasmJs {
// The wasmJsBrowserTest prints all executed tests as one unformatted string
// Have not found a way to suppress printing all this into console
browser()
nodejs()
}

applyDefaultHierarchyTemplate()

val macOsTargets =
listOf<KotlinTarget>(
macosX64(),
macosArm64(),
iosX64(),
iosArm64(),
iosSimulatorArm64(),
)

val linuxTargets =
listOf<KotlinTarget>(
linuxX64(),
linuxArm64(),
)

val windowsTargets =
listOf<KotlinTarget>(
mingwX64(),
)

sourceSets {
commonMain {
dependencies {
api(projects.jsonSchemaValidator)
}
}

val noJsMain by creating {
dependsOn(commonMain.get())
}

jvmMain {
dependsOn(noJsMain)
}

wasmJsMain {
dependsOn(noJsMain)
}

nativeMain {
dependsOn(noJsMain)
}

commonTest {
dependencies {
implementation(libs.kotest.assertions.core)
implementation(libs.kotest.framework.engine)
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
jvmTest {
dependencies {
implementation(libs.kotest.runner.junit5)
}
}
}

afterEvaluate {
fun Task.dependsOnTargetTests(targets: List<KotlinTarget>) {
targets.forEach {
if (it is KotlinTargetWithTests<*, *>) {
dependsOn(tasks.getByName("${it.name}Test"))
}
}
}
tasks.register("macOsAllTest") {
group = "verification"
description = "runs all tests for MacOS and IOS targets"
dependsOnTargetTests(macOsTargets)
}
tasks.register("windowsAllTest") {
group = "verification"
description = "runs all tests for Windows targets"
dependsOnTargetTests(windowsTargets)
}
tasks.register("linuxAllTest") {
group = "verification"
description = "runs all tests for Linux targets"
dependsOnTargetTests(linuxTargets)
dependsOn(tasks.getByName("jvmTest"))
dependsOn(tasks.getByName("jsTest"))
dependsOn(tasks.getByName("wasmJsTest"))
}
}
}

ktlint {
version.set(libs.versions.ktlint)
reporters {
reporter(ReporterType.HTML)
}
}

afterEvaluate {
val detektAllTask by tasks.register("detektAll") {
dependsOn(tasks.withType<Detekt>())
}

tasks.named("check").configure {
dependsOn(detektAllTask)
}
}
Loading
Loading