diff --git a/bgw-gui/build.gradle.kts b/bgw-gui/build.gradle.kts index 05acac444d..82360a25e5 100644 --- a/bgw-gui/build.gradle.kts +++ b/bgw-gui/build.gradle.kts @@ -1,92 +1 @@ -plugins { - val kotlinVersion = "2.0.0" - kotlin("multiplatform") - kotlin("plugin.serialization") version kotlinVersion - application - `maven-publish` -} - -group = "tools.aqua" -version = "1.0-SNAPSHOT" - -repositories { - jcenter() - mavenCentral() - maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") -} - -kotlin { - jvmToolchain(11) - jvm { - withJava() - testRuns["test"].executionTask.configure { - useJUnitPlatform() - } - } - js(IR) { - binaries.executable() - browser { - commonWebpackConfig { - cssSupport { - enabled.set(true) - } - } - } - } - sourceSets { - val commonMain by getting { - dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0") - } - } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - } - } - val jvmMain by getting { - dependencies { - implementation("io.ktor:ktor-server-core:2.3.11") - implementation("io.ktor:ktor-server-netty:2.3.11") - implementation("io.ktor:ktor-server-websockets:2.3.11") - implementation("io.ktor:ktor-server-html-builder-jvm:2.3.11") - implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.2") - implementation("me.friwi:jcefmaven:122.1.10") - } - } - val jvmTest by getting - val jsMain by getting { - dependencies { - implementation("org.jetbrains.kotlin-wrappers:kotlin-react:18.3.1-pre.758") - implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom:18.3.1-pre.758") - implementation("org.jetbrains.kotlin-wrappers:kotlin-emotion:11.11.4-pre.758") - } - } - val jsTest by getting - } -} - -application { - mainClass.set("tools.aqua.bgw.main.MainKt") -} - -tasks.named("jvmProcessResources") { - val jsBrowserDistribution = tasks.named("jsBrowserDistribution") - from(jsBrowserDistribution) -} - -tasks.named("run") { - dependsOn(tasks.named("jvmJar")) - classpath(tasks.named("jvmJar")) -} - -publishing { - publications { - create("maven") { - groupId = "tools.aqua" - artifactId = "bgw-gui" - version = "1.0-SNAPSHOT" - from(components["kotlin"]) - } - } -} \ No newline at end of file +plugins { id("tools.aqua.bgw.multiplatform-conventions") } \ No newline at end of file diff --git a/bgw-net/bgw-net-server/package-lock.json b/bgw-net/bgw-net-server/package-lock.json index c2793f0d14..1278f5f918 100644 --- a/bgw-net/bgw-net-server/package-lock.json +++ b/bgw-net/bgw-net-server/package-lock.json @@ -133,6 +133,10 @@ "workbox-webpack-plugin": "6.5.0" } }, + "build/flow-frontend": { + "version": "1.0.0", + "license": "UNLICENSED" + }, "node_modules/@ampproject/remapping": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", @@ -3249,9 +3253,8 @@ } }, "node_modules/@vaadin/flow-frontend": { - "version": "1.0.0", - "resolved": "file:build/flow-frontend", - "license": "UNLICENSED" + "resolved": "build/flow-frontend", + "link": true }, "node_modules/@vaadin/form-layout": { "version": "23.1.5", @@ -16517,7 +16520,7 @@ } }, "@vaadin/flow-frontend": { - "version": "1.0.0" + "version": "file:build/flow-frontend" }, "@vaadin/form-layout": { "version": "23.1.5", diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index faa736fb73..b4294d65b7 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -15,7 +15,7 @@ * limitations under the License. */ -plugins { `kotlin-dsl`.version("3.1.0") } +plugins { `kotlin-dsl` } repositories { gradlePluginPortal() @@ -44,6 +44,11 @@ dependencies { implementation(libs.gradle.taskTree) implementation(libs.gradle.vaadin) + implementation( + "org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:2.0.0") + implementation( + "org.jetbrains.kotlin.plugin.serialization:org.jetbrains.kotlin.plugin.serialization.gradle.plugin:2.0.0") + // black magic from https://github.com/gradle/gradle/issues/15383 implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) } diff --git a/buildSrc/src/main/kotlin/tools.aqua.bgw.multiplatform-conventions.gradle.kts b/buildSrc/src/main/kotlin/tools.aqua.bgw.multiplatform-conventions.gradle.kts new file mode 100644 index 0000000000..623e9635bb --- /dev/null +++ b/buildSrc/src/main/kotlin/tools.aqua.bgw.multiplatform-conventions.gradle.kts @@ -0,0 +1,100 @@ +/* + * Copyright 2024 The BoardGameWork Authors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.JavaExec +import org.gradle.api.tasks.bundling.Jar +import org.gradle.kotlin.dsl.* + +plugins { + kotlin("multiplatform") + kotlin("plugin.serialization") + application + `maven-publish` + id("io.gitlab.arturbosch.detekt") +} + +group = "tools.aqua" + +version = "1.0-SNAPSHOT" + +repositories { + jcenter() + mavenCentral() + maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") +} + +kotlin { + jvmToolchain(11) + jvm { + withJava() + testRuns["test"].executionTask.configure { useJUnitPlatform() } + } + js(IR) { + binaries.executable() + browser { commonWebpackConfig { cssSupport { enabled.set(true) } } } + } + sourceSets { + val commonMain by getting { + dependencies { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0") } + } + val commonTest by getting { dependencies { implementation(kotlin("test")) } } + val jvmMain by getting { + dependencies { + implementation("io.ktor:ktor-server-core:2.3.11") + implementation("io.ktor:ktor-server-netty:2.3.11") + implementation("io.ktor:ktor-server-websockets:2.3.11") + implementation("io.ktor:ktor-server-html-builder-jvm:2.3.11") + implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.2") + implementation("me.friwi:jcefmaven:122.1.10") + } + } + val jvmTest by getting + val jsMain by getting { + dependencies { + implementation("org.jetbrains.kotlin-wrappers:kotlin-react:18.3.1-pre.758") + implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom:18.3.1-pre.758") + implementation("org.jetbrains.kotlin-wrappers:kotlin-emotion:11.11.4-pre.758") + } + } + val jsTest by getting + } +} + +application { mainClass.set("tools.aqua.bgw.main.MainKt") } + +tasks.named("jvmProcessResources") { + val jsBrowserDistribution = tasks.named("jsBrowserDistribution") + from(jsBrowserDistribution) +} + +tasks.named("run") { + dependsOn(tasks.named("jvmJar")) + classpath(tasks.named("jvmJar")) +} + +publishing { + publications { + create("maven") { + groupId = "tools.aqua" + artifactId = "bgw-gui" + version = "1.0-SNAPSHOT" + from(components["kotlin"]) + } + } +} diff --git a/contrib/detekt-rules.yml b/contrib/detekt-rules.yml index 3edc942be3..f97c6f4d59 100644 --- a/contrib/detekt-rules.yml +++ b/contrib/detekt-rules.yml @@ -13,7 +13,7 @@ console-reports: - 'FileBasedFindingsReport' comments: - excludes: ['**/bgw-docs-examples/**'] + excludes: ['**/bgw-docs-examples/**', '**/bgw-net-server/**'] # Mostly enabled. Rationale: maintenance issues AbsentOrWrongFileLicense: @@ -39,7 +39,7 @@ comments: active: true complexity: - excludes: ['**/bgw-docs-examples/**'] + excludes: ['**/bgw-docs-examples/**', '**/bgw-net-server/**'] # Mostly disabled. Rationale: better suited for code review ComplexCondition: @@ -72,7 +72,7 @@ complexity: active: false coroutines: - excludes: ['**/bgw-docs-examples/**'] + excludes: ['**/bgw-docs-examples/**', '**/bgw-net-server/**'] # Mostly enabled. Rationale: indicative of errors GlobalCoroutineUsage: @@ -88,7 +88,7 @@ coroutines: active: true empty-blocks: - excludes: ['**/bgw-docs-examples/**'] + excludes: ['**/bgw-docs-examples/**', '**/bgw-net-server/**'] # Completely enabled. Rationale: indicative of errors EmptyCatchBlock: @@ -124,7 +124,7 @@ empty-blocks: active: true exceptions: - excludes: ['**/bgw-docs-examples/**'] + excludes: ['**/bgw-docs-examples/**', '**/bgw-net-server/**'] # Mostly enabled. Rationale: indicative of errors active: true @@ -159,7 +159,7 @@ exceptions: active: true naming: - excludes: ['**/bgw-docs-examples/**'] + excludes: ['**/bgw-docs-examples/**', '**/bgw-net-server/**'] # Mostly enabled. Rationale: principle of the least surprise active: true @@ -214,7 +214,7 @@ naming: active: true performance: - excludes: ['**/bgw-docs-examples/**'] + excludes: ['**/bgw-docs-examples/**', '**/bgw-net-server/**'] # Completely enabled. Rationale: indicative of errors active: true @@ -228,7 +228,7 @@ performance: active: true potential-bugs: - excludes: ['**/bgw-docs-examples/**'] + excludes: ['**/bgw-docs-examples/**', '**/bgw-net-server/**'] # Completely enabled. Rationale: indicative of errors active: true @@ -305,7 +305,7 @@ potential-bugs: active: true style: - excludes: ['**/bgw-docs-examples/**'] + excludes: ['**/bgw-docs-examples/**', '**/bgw-net-server/**'] # Partially enabled to complement Spotless. Rationale: helps consistency active: true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6df38f0e36..0bb3c855a7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ # Platforms -kotlin = "1.7.10" +kotlin = "1.9.10" spring = "2.7.14" vaadin = "23.1.6" @@ -77,7 +77,7 @@ vaadin-bom = { group = "com.vaadin", name = "vaadin-bom", version.ref = "vaadin" # Gradle Plugins gradle-dokka = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "kotlin" } -gradle-kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version = "2.0.0" } +gradle-kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } gradle-kotlin-allopen = { group = "org.jetbrains.kotlin", name = "kotlin-allopen", version.ref = "kotlin" } gradle-kotlin-noarg = { group = "org.jetbrains.kotlin", name = "kotlin-noarg", version.ref = "kotlin" } diff --git a/settings.gradle.kts b/settings.gradle.kts index cd3d2cd209..ca6ec78450 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -18,12 +18,12 @@ rootProject.name = "bgw" include( + "bgw-gui", "bgw-docs", "bgw-examples:bgw-docs-examples", "bgw-examples:bgw-maumau-example", "bgw-examples:bgw-sudoku-example", "bgw-examples:bgw-tetris-example", - "bgw-gui", "bgw-net:bgw-net-client", "bgw-net:bgw-net-common", "bgw-net:bgw-net-server",