diff --git a/.github/workflows/publish-v4-release.yml b/.github/workflows/publish-v4-release.yml index fba48dc5e..5570db3b5 100644 --- a/.github/workflows/publish-v4-release.yml +++ b/.github/workflows/publish-v4-release.yml @@ -53,7 +53,7 @@ jobs: test-and-publish-v4-release: name: Publish v4 Release needs: test-pre-release - runs-on: macos-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 @@ -82,35 +82,35 @@ jobs: SIMBOT_RELEASES_ONLY: true SIMBOT_SNAPSHOT_ONLY: false - publish-v4-snapshot: - name: Publish V4 snapshot - runs-on: macos-latest - needs: test-and-publish-v4-release - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - distribution: ${{ env.JAVA_DISTRIBUTION }} - java-version: ${{ env.JAVA_VERSION }} - cache: 'gradle' - - # setup Gradle - - name: Gradle publish snapshot - uses: gradle/actions/setup-gradle@v3 - with: - gradle-version: ${{ env.GRADLE_VERSION }} - arguments: | - publishToSonatype - closeAndReleaseStagingRepositories - -s - --warning-mode all - -x test - --build-cache - -Porg.gradle.jvmargs="-XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8" - env: - SIMBOT_IS_SNAPSHOT: true - SIMBOT_SNAPSHOT_ONLY: true - SIMBOT_RELEASES_ONLY: false +# publish-v4-snapshot: +# name: Publish V4 snapshot +# runs-on: ubuntu-latest +# needs: test-and-publish-v4-release +# steps: +# - uses: actions/checkout@v4 +# - uses: actions/setup-java@v4 +# with: +# distribution: ${{ env.JAVA_DISTRIBUTION }} +# java-version: ${{ env.JAVA_VERSION }} +# cache: 'gradle' +# +# # setup Gradle +# - name: Gradle publish snapshot +# uses: gradle/actions/setup-gradle@v3 +# with: +# gradle-version: ${{ env.GRADLE_VERSION }} +# arguments: | +# publishToSonatype +# closeAndReleaseStagingRepositories +# -s +# --warning-mode all +# -x test +# --build-cache +# -Porg.gradle.jvmargs="-XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8" +# env: +# SIMBOT_IS_SNAPSHOT: true +# SIMBOT_SNAPSHOT_ONLY: true +# SIMBOT_RELEASES_ONLY: false deploy-doc: name: Deploy V4 API Doc diff --git a/.github/workflows/publish-v4-snapshot.yml b/.github/workflows/publish-v4-snapshot.yml index f7bab78b2..992df1246 100644 --- a/.github/workflows/publish-v4-snapshot.yml +++ b/.github/workflows/publish-v4-snapshot.yml @@ -69,7 +69,7 @@ jobs: publish-v4-snapshot: name: Publish v4 snapshot needs: run-tests - runs-on: macos-latest + runs-on: ubuntu-latest steps: # 检出仓库代码 - uses: actions/checkout@v4 diff --git a/.idea/dictionaries/forte.xml b/.idea/dictionaries/forte.xml index ea4b87141..2cfedd3a0 100644 --- a/.idea/dictionaries/forte.xml +++ b/.idea/dictionaries/forte.xml @@ -1,3 +1,7 @@ - + + + suspendrunner + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 63b575a44..bcfdec6df 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,6 +22,8 @@ */ import io.gitlab.arturbosch.detekt.Detekt +import love.forte.plugin.suspendtrans.* +import love.forte.plugin.suspendtrans.gradle.SuspendTransformGradleExtension plugins { idea @@ -30,6 +32,9 @@ plugins { alias(libs.plugins.detekt) id("simbot.nexus-publish") id("simbot.changelog-generator") + alias(libs.plugins.suspendTransform) apply false + // id("love.forte.plugin.suspend-transform") version "2.1.0-0.9.4" apply false + // https://www.jetbrains.com/help/qodana/code-coverage.html // https://github.com/Kotlin/kotlinx-kover @@ -81,8 +86,11 @@ subprojects { } applyKover(root) - } + if (plugins.hasPlugin(libs.plugins.suspendTransform.get().pluginId)) { + configureSuspendTransform() + } + } } dependencies { @@ -173,12 +181,199 @@ idea { } // https://kotlinlang.org/docs/js-project-setup.html#node-js -rootProject.plugins.withType { - rootProject.the().apply { - // CI 中配置环境,不再单独下载 - if (isCi) { - download = false - } +// rootProject.plugins.withType { +// rootProject.the().apply { +// // CI 中配置环境,不再单独下载 +// // if (isCi) { +// // download = false +// // } +// } +// // "true" for default behavior +// } + +// region Suspend Transform configs +@Suppress("MaxLineLength") +object SuspendTransforms { + private val javaIncludeAnnotationApi4JClassInfo = ClassInfo("love.forte.simbot.annotations", "Api4J") + private val javaIncludeAnnotationApi4J = IncludeAnnotation(javaIncludeAnnotationApi4JClassInfo).apply { + includeProperty = true + } + private val javaIncludeAnnotations = listOf(javaIncludeAnnotationApi4J) + + private val jsIncludeAnnotationApi4JsClassInfo = ClassInfo("love.forte.simbot.annotations", "Api4Js") + private val jsIncludeAnnotationApi4Js = IncludeAnnotation(jsIncludeAnnotationApi4JsClassInfo).apply { + includeProperty = true + } + private val jsIncludeAnnotations = listOf(jsIncludeAnnotationApi4Js) + + + private val SuspendReserveClassInfo = ClassInfo( + packageName = "love.forte.simbot.suspendrunner.reserve", + className = "SuspendReserve", + ) + + /** + * JvmBlocking + */ + val jvmBlockingTransformer = SuspendTransformConfiguration.jvmBlockingTransformer.copy( + syntheticFunctionIncludeAnnotations = javaIncludeAnnotations, + transformFunctionInfo = FunctionInfo("love.forte.simbot.suspendrunner", null, "$\$runInBlocking"), + copyAnnotationExcludes = SuspendTransformConfiguration.jvmBlockingTransformer.copyAnnotationExcludes + SuspendTransformConfiguration.jvmBlockingTransformer.markAnnotation.classInfo + ) + + /** + * JvmAsync + */ + val jvmAsyncTransformer = SuspendTransformConfiguration.jvmAsyncTransformer.copy( + syntheticFunctionIncludeAnnotations = javaIncludeAnnotations, + transformFunctionInfo = FunctionInfo("love.forte.simbot.suspendrunner", null, "$\$runInAsyncNullable"), + copyAnnotationExcludes = SuspendTransformConfiguration.jvmAsyncTransformer.copyAnnotationExcludes + SuspendTransformConfiguration.jvmAsyncTransformer.markAnnotation.classInfo + ) + + /** + * JvmReserve + */ + val jvmReserveTransformer = SuspendTransformConfiguration.jvmAsyncTransformer.copy( + syntheticFunctionIncludeAnnotations = javaIncludeAnnotations, + transformFunctionInfo = FunctionInfo("love.forte.simbot.suspendrunner", null, "$\$asReserve"), + copyAnnotationExcludes = SuspendTransformConfiguration.jvmAsyncTransformer.copyAnnotationExcludes + SuspendTransformConfiguration.jvmAsyncTransformer.markAnnotation.classInfo, + transformReturnType = SuspendReserveClassInfo, + transformReturnTypeGeneric = true, + ) + + /** + * JsPromise + */ + val jsPromiseTransformer = SuspendTransformConfiguration.jsPromiseTransformer.copy( + syntheticFunctionIncludeAnnotations = javaIncludeAnnotations, + transformFunctionInfo = FunctionInfo("love.forte.simbot.suspendrunner", null, "$\$runInPromise"), + copyAnnotationExcludes = SuspendTransformConfiguration.jsPromiseTransformer.copyAnnotationExcludes + SuspendTransformConfiguration.jsPromiseTransformer.markAnnotation.classInfo, + ) + + //region @JvmSuspendTrans + private val suspendTransMarkAnnotationClassInfo = ClassInfo("love.forte.simbot.suspendrunner", "SuspendTrans") + + private val jvmSuspendTransMarkAnnotationForBlocking = MarkAnnotation( + suspendTransMarkAnnotationClassInfo, + baseNameProperty = "blockingBaseName", + suffixProperty = "blockingSuffix", + asPropertyProperty = "blockingAsProperty", + defaultSuffix = SuspendTransformConfiguration.jvmBlockingAnnotationInfo.defaultSuffix, + ) + private val jvmSuspendTransMarkAnnotationForAsync = MarkAnnotation( + suspendTransMarkAnnotationClassInfo, + baseNameProperty = "asyncBaseName", + suffixProperty = "asyncSuffix", + asPropertyProperty = "asyncAsProperty", + defaultSuffix = SuspendTransformConfiguration.jvmAsyncAnnotationInfo.defaultSuffix, + ) + private val jvmSuspendTransMarkAnnotationForReserve = MarkAnnotation( + suspendTransMarkAnnotationClassInfo, + baseNameProperty = "reserveBaseName", + suffixProperty = "reserveSuffix", + asPropertyProperty = "reserveAsProperty", + defaultSuffix = "Reserve", + ) + private val jsSuspendTransMarkAnnotationForPromise = MarkAnnotation( + suspendTransMarkAnnotationClassInfo, + baseNameProperty = "jsPromiseBaseName", + suffixProperty = "jsPromiseSuffix", + asPropertyProperty = "jsPromiseAsProperty", + defaultSuffix = "Async", + ) + + val suspendTransTransformerForJvmBlocking = jvmBlockingTransformer.copy( + markAnnotation = jvmSuspendTransMarkAnnotationForBlocking, + copyAnnotationExcludes = SuspendTransformConfiguration.jvmBlockingTransformer.copyAnnotationExcludes + jvmSuspendTransMarkAnnotationForBlocking.classInfo + ) + + val suspendTransTransformerForJvmAsync = jvmAsyncTransformer.copy( + markAnnotation = jvmSuspendTransMarkAnnotationForAsync, + copyAnnotationExcludes = SuspendTransformConfiguration.jvmAsyncTransformer.copyAnnotationExcludes + jvmSuspendTransMarkAnnotationForAsync.classInfo + ) + + val suspendTransTransformerForJvmReserve = jvmReserveTransformer.copy( + markAnnotation = jvmSuspendTransMarkAnnotationForReserve, + copyAnnotationExcludes = jvmReserveTransformer.copyAnnotationExcludes + jvmSuspendTransMarkAnnotationForReserve.classInfo, + ) + + val suspendTransTransformerForJsPromise = jsPromiseTransformer.copy( + markAnnotation = jvmSuspendTransMarkAnnotationForReserve, + copyAnnotationExcludes = jsPromiseTransformer.copyAnnotationExcludes + jsSuspendTransMarkAnnotationForPromise.classInfo, + ) + //endregion + + //region @JvmSuspendTransProperty + private val jvmSuspendTransPropMarkAnnotationClassInfo = + ClassInfo("love.forte.simbot.suspendrunner", "SuspendTransProperty") + + private val jvmSuspendTransPropMarkAnnotationForBlocking = MarkAnnotation( + jvmSuspendTransPropMarkAnnotationClassInfo, + baseNameProperty = "blockingBaseName", + suffixProperty = "blockingSuffix", + asPropertyProperty = "blockingAsProperty", + defaultSuffix = "", + defaultAsProperty = true + ) + private val jvmSuspendTransPropMarkAnnotationForAsync = MarkAnnotation( + jvmSuspendTransPropMarkAnnotationClassInfo, + baseNameProperty = "asyncBaseName", + suffixProperty = "asyncSuffix", + asPropertyProperty = "asyncAsProperty", + defaultSuffix = SuspendTransformConfiguration.jvmAsyncAnnotationInfo.defaultSuffix, + defaultAsProperty = true + ) + private val jvmSuspendTransPropMarkAnnotationForReserve = MarkAnnotation( + jvmSuspendTransPropMarkAnnotationClassInfo, + baseNameProperty = "reserveBaseName", + suffixProperty = "reserveSuffix", + asPropertyProperty = "reserveAsProperty", + defaultSuffix = "Reserve", + defaultAsProperty = true + ) + + val jvmSuspendTransPropTransformerForBlocking = jvmBlockingTransformer.copy( + markAnnotation = jvmSuspendTransPropMarkAnnotationForBlocking, + copyAnnotationExcludes = SuspendTransformConfiguration.jvmBlockingTransformer.copyAnnotationExcludes + jvmSuspendTransPropMarkAnnotationForBlocking.classInfo + ) + + val jvmSuspendTransPropTransformerForAsync = jvmAsyncTransformer.copy( + markAnnotation = jvmSuspendTransPropMarkAnnotationForAsync, + copyAnnotationExcludes = SuspendTransformConfiguration.jvmAsyncTransformer.copyAnnotationExcludes + jvmSuspendTransPropMarkAnnotationForAsync.classInfo + ) + + val jvmSuspendTransPropTransformerForReserve = jvmReserveTransformer.copy( + markAnnotation = jvmSuspendTransPropMarkAnnotationForReserve, + copyAnnotationExcludes = jvmReserveTransformer.copyAnnotationExcludes + jvmSuspendTransPropMarkAnnotationForReserve.classInfo + ) + //endregion +} + +fun Project.configureSuspendTransform() { + extensions.configure("suspendTransform") { + includeRuntime = false + includeAnnotation = false + + addJvmTransformers( + // @JvmBlocking + SuspendTransforms.jvmBlockingTransformer, + // @JvmAsync + SuspendTransforms.jvmAsyncTransformer, + + // @JvmSuspendTrans + SuspendTransforms.suspendTransTransformerForJvmBlocking, + SuspendTransforms.suspendTransTransformerForJvmAsync, + SuspendTransforms.suspendTransTransformerForJvmReserve, + + // @JvmSuspendTransProperty + SuspendTransforms.jvmSuspendTransPropTransformerForBlocking, + SuspendTransforms.jvmSuspendTransPropTransformerForAsync, + SuspendTransforms.jvmSuspendTransPropTransformerForReserve, + ) + + // addJsTransformers( + // SuspendTransforms.suspendTransTransformerForJsPromise, + // ) } - // "true" for default behavior } +// endregion diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 7d4031160..caebb246f 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -29,7 +29,7 @@ plugins { repositories { mavenCentral() gradlePluginPortal() - mavenLocal() + // mavenLocal() } val kotlinVersion: String = libs.versions.kotlin.get() @@ -38,13 +38,15 @@ dependencies { implementation(kotlin("gradle-plugin", kotlinVersion)) implementation(kotlin("serialization", kotlinVersion)) implementation(kotlin("power-assert", kotlinVersion)) + // compileOnly(kotlin("compiler", kotlinVersion)) + // compileOnly(kotlin("compiler-embeddable", kotlinVersion)) implementation(libs.bundles.dokka) // see https://github.com/gradle-nexus/publish-plugin implementation(libs.gradleNexusPublishPlugin) // suspend transform - implementation(libs.suspend.transform.gradle) + // implementation(libs.suspend.transform.gradle) // gradle common implementation(libs.bundles.gradle.common) diff --git a/buildSrc/src/main/kotlin/JvmConfig.kt b/buildSrc/src/main/kotlin/JvmConfig.kt index a356bae59..bf732d6f1 100644 --- a/buildSrc/src/main/kotlin/JvmConfig.kt +++ b/buildSrc/src/main/kotlin/JvmConfig.kt @@ -28,15 +28,13 @@ import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.getByName import org.gradle.kotlin.dsl.withType import org.gradle.process.CommandLineArgumentProvider -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinBaseExtension import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget -@OptIn(ExperimentalKotlinGradlePluginApi::class) inline fun KotlinJvmTarget.configJava(crossinline block: KotlinJvmTarget.() -> Unit = {}) { withJava() compilerOptions { @@ -56,7 +54,7 @@ inline fun KotlinJvmTarget.configJava(crossinline block: KotlinJvmTarget.() -> U } -fun KotlinTopLevelExtension.configJavaToolchain(jdkVersion: Int) { +fun KotlinBaseExtension.configJavaToolchain(jdkVersion: Int) { jvmToolchain(jdkVersion) } diff --git a/buildSrc/src/main/kotlin/P.kt b/buildSrc/src/main/kotlin/P.kt index 06c03cdce..2f3ca25cb 100644 --- a/buildSrc/src/main/kotlin/P.kt +++ b/buildSrc/src/main/kotlin/P.kt @@ -47,8 +47,8 @@ fun isSnapshot(): Boolean = _isSnapshot @Suppress("MemberVisibilityCanBePrivate") sealed class P(override val group: String) : ProjectDetail() { companion object { - const val VERSION = "4.8.0" - const val NEXT_VERSION = "4.8.1" + const val VERSION = "4.9.0" + const val NEXT_VERSION = "4.9.0" const val SNAPSHOT_VERSION = "$VERSION-SNAPSHOT" const val NEXT_SNAPSHOT_VERSION = "$NEXT_VERSION-SNAPSHOT" diff --git a/buildSrc/src/main/kotlin/SuspendTransforms.kt b/buildSrc/src/main/kotlin/SuspendTransforms.kt deleted file mode 100644 index 69d28cb70..000000000 --- a/buildSrc/src/main/kotlin/SuspendTransforms.kt +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2023-2024. ForteScarlet. - * - * Project https://github.com/simple-robot/simpler-robot - * Email ForteScarlet@163.com - * - * This file is part of the Simple Robot Library. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Lesser GNU General Public License for more details. - * - * You should have received a copy of the Lesser GNU General Public License - * along with this program. If not, see . - * - */ - -import love.forte.plugin.suspendtrans.* - -/* - * Copyright (c) 2023 ForteScarlet - * - * 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x 、simbot3 等) 的一部分。 - * simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。 - * 发布 simply-robot 是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。 - * - * 你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看: - * https://www.gnu.org/licenses - * https://www.gnu.org/licenses/gpl-3.0-standalone.html - * https://www.gnu.org/licenses/lgpl-3.0-standalone.html - */ - - -object SuspendTransforms { - private val javaIncludeAnnotationApi4JClassInfo = ClassInfo("love.forte.simbot.annotations", "Api4J") - private val javaIncludeAnnotationApi4J = IncludeAnnotation(javaIncludeAnnotationApi4JClassInfo) - private val javaIncludeAnnotations = listOf(javaIncludeAnnotationApi4J) - - private val jsIncludeAnnotationApi4JsClassInfo = ClassInfo("love.forte.simbot.annotations", "Api4Js") - private val jsIncludeAnnotationApi4Js = IncludeAnnotation(jsIncludeAnnotationApi4JsClassInfo) - private val jsIncludeAnnotations = listOf(jsIncludeAnnotationApi4Js) - - - private val SuspendReserveClassInfo = ClassInfo( - packageName = "love.forte.simbot.suspendrunner.reserve", - className = "SuspendReserve", - - ) - - /** - * JvmBlocking - */ - val jvmBlockingTransformer = SuspendTransformConfiguration.jvmBlockingTransformer.copy( - syntheticFunctionIncludeAnnotations = javaIncludeAnnotations, - transformFunctionInfo = FunctionInfo("love.forte.simbot.suspendrunner", null, "$\$runInBlocking"), - copyAnnotationExcludes = SuspendTransformConfiguration.jvmBlockingTransformer.copyAnnotationExcludes + SuspendTransformConfiguration.jvmBlockingTransformer.markAnnotation.classInfo - ) - - /** - * JvmAsync - */ - val jvmAsyncTransformer = SuspendTransformConfiguration.jvmAsyncTransformer.copy( - syntheticFunctionIncludeAnnotations = javaIncludeAnnotations, - transformFunctionInfo = FunctionInfo("love.forte.simbot.suspendrunner", null, "$\$runInAsyncNullable"), - copyAnnotationExcludes = SuspendTransformConfiguration.jvmAsyncTransformer.copyAnnotationExcludes + SuspendTransformConfiguration.jvmAsyncTransformer.markAnnotation.classInfo - ) - - /** - * JvmReserve - */ - val jvmReserveTransformer = SuspendTransformConfiguration.jvmAsyncTransformer.copy( - syntheticFunctionIncludeAnnotations = javaIncludeAnnotations, - transformFunctionInfo = FunctionInfo("love.forte.simbot.suspendrunner", null, "$\$asReserve"), - copyAnnotationExcludes = SuspendTransformConfiguration.jvmAsyncTransformer.copyAnnotationExcludes + SuspendTransformConfiguration.jvmAsyncTransformer.markAnnotation.classInfo, - transformReturnType = SuspendReserveClassInfo, - transformReturnTypeGeneric = true, - ) - - /** - * JsPromise - */ - val jsPromiseTransformer = SuspendTransformConfiguration.jsPromiseTransformer.copy( - syntheticFunctionIncludeAnnotations = javaIncludeAnnotations, - transformFunctionInfo = FunctionInfo("love.forte.simbot.suspendrunner", null, "$\$runInPromise"), - copyAnnotationExcludes = SuspendTransformConfiguration.jsPromiseTransformer.copyAnnotationExcludes + SuspendTransformConfiguration.jsPromiseTransformer.markAnnotation.classInfo, - ) - - //region @JvmSuspendTrans - private val suspendTransMarkAnnotationClassInfo = ClassInfo("love.forte.simbot.suspendrunner", "SuspendTrans") - - private val jvmSuspendTransMarkAnnotationForBlocking = MarkAnnotation( - suspendTransMarkAnnotationClassInfo, - baseNameProperty = "blockingBaseName", - suffixProperty = "blockingSuffix", - asPropertyProperty = "blockingAsProperty", - defaultSuffix = SuspendTransformConfiguration.jvmBlockingAnnotationInfo.defaultSuffix, - ) - private val jvmSuspendTransMarkAnnotationForAsync = MarkAnnotation( - suspendTransMarkAnnotationClassInfo, - baseNameProperty = "asyncBaseName", - suffixProperty = "asyncSuffix", - asPropertyProperty = "asyncAsProperty", - defaultSuffix = SuspendTransformConfiguration.jvmAsyncAnnotationInfo.defaultSuffix, - ) - private val jvmSuspendTransMarkAnnotationForReserve = MarkAnnotation( - suspendTransMarkAnnotationClassInfo, - baseNameProperty = "reserveBaseName", - suffixProperty = "reserveSuffix", - asPropertyProperty = "reserveAsProperty", - defaultSuffix = "Reserve", - ) - private val jsSuspendTransMarkAnnotationForPromise = MarkAnnotation( - suspendTransMarkAnnotationClassInfo, - baseNameProperty = "jsPromiseBaseName", - suffixProperty = "jsPromiseSuffix", - asPropertyProperty = "jsPromiseAsProperty", - defaultSuffix = "Async", - ) - - val suspendTransTransformerForJvmBlocking = jvmBlockingTransformer.copy( - markAnnotation = jvmSuspendTransMarkAnnotationForBlocking, - copyAnnotationExcludes = SuspendTransformConfiguration.jvmBlockingTransformer.copyAnnotationExcludes + jvmSuspendTransMarkAnnotationForBlocking.classInfo - ) - - val suspendTransTransformerForJvmAsync = jvmAsyncTransformer.copy( - markAnnotation = jvmSuspendTransMarkAnnotationForAsync, - copyAnnotationExcludes = SuspendTransformConfiguration.jvmAsyncTransformer.copyAnnotationExcludes + jvmSuspendTransMarkAnnotationForAsync.classInfo - ) - - val suspendTransTransformerForJvmReserve = jvmReserveTransformer.copy( - markAnnotation = jvmSuspendTransMarkAnnotationForReserve, - copyAnnotationExcludes = jvmReserveTransformer.copyAnnotationExcludes + jvmSuspendTransMarkAnnotationForReserve.classInfo, - ) - - val suspendTransTransformerForJsPromise = jsPromiseTransformer.copy( - markAnnotation = jvmSuspendTransMarkAnnotationForReserve, - copyAnnotationExcludes = jsPromiseTransformer.copyAnnotationExcludes + jsSuspendTransMarkAnnotationForPromise.classInfo, - ) - //endregion - - //region @JvmSuspendTransProperty - private val jvmSuspendTransPropMarkAnnotationClassInfo = - ClassInfo("love.forte.simbot.suspendrunner", "SuspendTransProperty") - - private val jvmSuspendTransPropMarkAnnotationForBlocking = MarkAnnotation( - jvmSuspendTransPropMarkAnnotationClassInfo, - baseNameProperty = "blockingBaseName", - suffixProperty = "blockingSuffix", - asPropertyProperty = "blockingAsProperty", - defaultSuffix = "", - defaultAsProperty = true - ) - private val jvmSuspendTransPropMarkAnnotationForAsync = MarkAnnotation( - jvmSuspendTransPropMarkAnnotationClassInfo, - baseNameProperty = "asyncBaseName", - suffixProperty = "asyncSuffix", - asPropertyProperty = "asyncAsProperty", - defaultSuffix = SuspendTransformConfiguration.jvmAsyncAnnotationInfo.defaultSuffix, - defaultAsProperty = true - ) - private val jvmSuspendTransPropMarkAnnotationForReserve = MarkAnnotation( - jvmSuspendTransPropMarkAnnotationClassInfo, - baseNameProperty = "reserveBaseName", - suffixProperty = "reserveSuffix", - asPropertyProperty = "reserveAsProperty", - defaultSuffix = "Reserve", - defaultAsProperty = true - ) - - val jvmSuspendTransPropTransformerForBlocking = jvmBlockingTransformer.copy( - markAnnotation = jvmSuspendTransPropMarkAnnotationForBlocking, - copyAnnotationExcludes = SuspendTransformConfiguration.jvmBlockingTransformer.copyAnnotationExcludes + jvmSuspendTransPropMarkAnnotationForBlocking.classInfo - ) - - val jvmSuspendTransPropTransformerForAsync = jvmAsyncTransformer.copy( - markAnnotation = jvmSuspendTransPropMarkAnnotationForAsync, - copyAnnotationExcludes = SuspendTransformConfiguration.jvmAsyncTransformer.copyAnnotationExcludes + jvmSuspendTransPropMarkAnnotationForAsync.classInfo - ) - - val jvmSuspendTransPropTransformerForReserve = jvmReserveTransformer.copy( - markAnnotation = jvmSuspendTransPropMarkAnnotationForReserve, - copyAnnotationExcludes = jvmReserveTransformer.copyAnnotationExcludes + jvmSuspendTransPropMarkAnnotationForReserve.classInfo - ) - //endregion - - -} - - - - diff --git a/buildSrc/src/main/kotlin/simbot.suspend-transform-configure.gradle.kts b/buildSrc/src/main/kotlin/simbot.suspend-transform-configure.gradle.kts deleted file mode 100644 index c634ca0cd..000000000 --- a/buildSrc/src/main/kotlin/simbot.suspend-transform-configure.gradle.kts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2024. ForteScarlet. - * - * Project https://github.com/simple-robot/simpler-robot - * Email ForteScarlet@163.com - * - * This file is part of the Simple Robot Library. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Lesser GNU General Public License for more details. - * - * You should have received a copy of the Lesser GNU General Public License - * along with this program. If not, see . - * - */ - -plugins { - id("love.forte.plugin.suspend-transform") -} - -suspendTransform { - includeRuntime = false - includeAnnotation = false - - addJvmTransformers( - // @JvmBlocking - SuspendTransforms.jvmBlockingTransformer, - // @JvmAsync - SuspendTransforms.jvmAsyncTransformer, - - // @JvmSuspendTrans - SuspendTransforms.suspendTransTransformerForJvmBlocking, - SuspendTransforms.suspendTransTransformerForJvmAsync, - SuspendTransforms.suspendTransTransformerForJvmReserve, - - // @JvmSuspendTransProperty - SuspendTransforms.jvmSuspendTransPropTransformerForBlocking, - SuspendTransforms.jvmSuspendTransPropTransformerForAsync, - SuspendTransforms.jvmSuspendTransPropTransformerForReserve, - ) - - // addJsTransformers( - // SuspendTransforms.suspendTransTransformerForJsPromise, - // ) -} diff --git a/gradle.properties b/gradle.properties index ea4ad86c4..fd6b9c4bc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -44,6 +44,8 @@ org.gradle.caching=true #org.gradle.configuration-cache=true #org.gradle.configuration-cache.problems=warn +# https://kotlinlang.org/docs/multiplatform-publish-lib.html#host-requirements +kotlin.native.enableKlibsCrossCompilation=true # https://kotlinlang.org/docs/gradle-compilation-and-caches.html#the-new-kotlin-compiler #kotlin.experimental.tryK2=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 90ff8f50b..2de2b56d9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,24 +1,23 @@ [versions] -kotlin = "2.0.20" +kotlin = "2.1.0" dokka = "1.9.20" kotlinx-coroutines = "1.9.0" kotlinx-serialization = "1.7.3" kotlinx-io = "0.6.0" spring-boot-v2 = "2.7.18" spring-boot-v3 = "3.2.1" -openjdk-jmh = "1.36" ktor = "2.3.12" slf4j = "2.0.16" # https://kotlinlang.org/docs/ksp-quickstart.html # https://github.com/google/ksp -ksp = "2.0.20-1.0.25" +ksp = "2.1.0-1.0.29" # https://square.github.io/kotlinpoet/ kotlinPoet = "2.0.0" # https://github.com/Kotlin/kotlinx-benchmark #kotlinxBenchmark = "0.4.11" reactor = "3.7.0" # simbots -suspendTransform = "2.0.20-0.9.4" +suspendTransform = "2.1.0-0.9.4" gradleCommon = "0.6.0" # tests mockk = "1.13.13" @@ -46,50 +45,36 @@ kotlinx-coroutines-reactive = { group = "org.jetbrains.kotlinx", name = "kotlinx kotlinx-coroutines-reactor = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-reactor", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-rx2 = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-rx2", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-rx3 = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-rx3", version.ref = "kotlinx-coroutines" } -kotlinx-coroutines-guava = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-guava", version.ref = "kotlinx-coroutines" } -kotlinx-coroutines-slf4j = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-slf4j", version.ref = "kotlinx-coroutines" } -kotlinx-coroutines-debug = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-debug", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } # kotlinx-serialization kotlinx-serialization-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version.ref = "kotlinx-serialization" } kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization" } -kotlinx-serialization-hocon = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-hocon", version.ref = "kotlinx-serialization" } -kotlinx-serialization-protobuf = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-protobuf", version.ref = "kotlinx-serialization" } -kotlinx-serialization-cbor = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-cbor", version.ref = "kotlinx-serialization" } kotlinx-serialization-properties = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-properties", version.ref = "kotlinx-serialization" } # kotlinx-io kotlinx-io-core = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "kotlinx-io" } -kotlinx-io-bytestring = { module = "org.jetbrains.kotlinx:kotlinx-io-bytestring", version.ref = "kotlinx-io" } # slf4j slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" } -slf4j-nop = { group = "org.slf4j", name = "slf4j-nop", version.ref = "slf4j" } # javax -javax-inject = "javax.inject:javax.inject:1" javax-annotation-api = "javax.annotation:javax.annotation-api:1.3.2" # spring-boot-v2 -spring-boot-v2-dependencies = { group = "org.springframework.boot", name = "spring-boot-dependencies", version.ref = "spring-boot-v2" } spring-boot-v2-autoconfigure = { group = "org.springframework.boot", name = "spring-boot-autoconfigure", version.ref = "spring-boot-v2" } spring-boot-v2-logging = { group = "org.springframework.boot", name = "spring-boot-starter-logging", version.ref = "spring-boot-v2" } -spring-boot-v2-actuator = { group = "org.springframework.boot", name = "spring-boot-starter-actuator", version.ref = "spring-boot-v2" } spring-boot-v2-configuration-processor = { group = "org.springframework.boot", name = "spring-boot-configuration-processor", version.ref = "spring-boot-v2" } spring-boot-v2-aop = { group = "org.springframework.boot", name = "spring-boot-starter-aop", version.ref = "spring-boot-v2" } spring-boot-v2-test = { group = "org.springframework.boot", name = "spring-boot-starter-test", version.ref = "spring-boot-v2" } -spring-boot-v2-webflux = { group = "org.springframework.boot", name = "spring-boot-starter-webflux", version.ref = "spring-boot-v2" } # spring-boot-v3 spring-boot-v3-dependencies = { group = "org.springframework.boot", name = "spring-boot-dependencies", version.ref = "spring-boot-v3" } spring-boot-v3-autoconfigure = { group = "org.springframework.boot", name = "spring-boot-autoconfigure" } # , version.ref = "spring-boot-v3" spring-boot-v3-logging = { group = "org.springframework.boot", name = "spring-boot-starter-logging" } # , version.ref = "spring-boot-v3" -spring-boot-v3-actuator = { group = "org.springframework.boot", name = "spring-boot-starter-actuator" } # , version.ref = "spring-boot-v3" spring-boot-v3-configuration-processor = { group = "org.springframework.boot", name = "spring-boot-configuration-processor", version.ref = "spring-boot-v3" } spring-boot-v3-aop = { group = "org.springframework.boot", name = "spring-boot-starter-aop" } # , version.ref = "spring-boot-v3" spring-boot-v3-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } # , version.ref = "spring-boot-v3" -spring-boot-v3-webflux = { group = "org.springframework.boot", name = "spring-boot-starter-webflux" } # , version.ref = "spring-boot-v3" # spring-boot-data #spring-boot-data-redis-reactive = { module = "org.springframework.boot:spring-boot-starter-data-redis-reactive", version.ref = "spring-boot" } @@ -97,17 +82,9 @@ spring-boot-v3-webflux = { group = "org.springframework.boot", name = "spring-bo # lmax-disruptor lmax-disruptor = "com.lmax:disruptor:3.4.4" -# jmh -openjdk-jmh-core = { group = "org.openjdk.jmh", name = "jmh-core", version.ref = "openjdk-jmh" } -openjdk-jmh-generator-annprocess = { group = "org.openjdk.jmh", name = "jmh-generator-annprocess", version.ref = "openjdk-jmh" } - # ktor -ktor-io = { group = "io.ktor", name = "ktor-io", version.ref = "ktor" } ktor-http = { group = "io.ktor", name = "ktor-http", version.ref = "ktor" } -ktor-server-core = { group = "io.ktor", name = "ktor-server-core", version.ref = "ktor" } -ktor-server-netty = { group = "io.ktor", name = "ktor-server-netty", version.ref = "ktor" } - ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" } ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" } ktor-client-js = { group = "io.ktor", name = "ktor-client-js", version.ref = "ktor" } @@ -142,7 +119,6 @@ mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" } [plugins] ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } #kotlinxBenchmark = { id = "org.jetbrains.kotlinx.benchmark", version.ref = "kotlinxBenchmark" } -kotlinAllOpen = { id = "org.jetbrains.kotlin.plugin.allopen", version.ref = "kotlin" } detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } # Kover # https://www.jetbrains.com/help/qodana/code-coverage.html @@ -156,6 +132,8 @@ spring = { id = "org.springframework.boot", version.ref = "spring-boot-v3" } spring-dependencyManagement = { id = "io.spring.dependency-management", version = "1.1.5" } kotlin-plugin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" } +suspendTransform = { id = "love.forte.plugin.suspend-transform", version.ref = "suspendTransform" } + [bundles] gradle-common = ["gradle-common-core", "gradle-common-multiplatform", "gradle-common-publication"] dokka = ["dokka-plugin", "dokka-core", "dokka-base"] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8069aef9e..40af5ccdb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -4,7 +4,7 @@ # Project https://github.com/simple-robot/simpler-robot # Email ForteScarlet@163.com # -# This file is part of the Simple Robot Library. +# This file is part of the Simple Robot Library (Alias: simple-robot, simbot, etc.). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by @@ -23,7 +23,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index b914d6ff4..eb869ec25 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -286,6 +286,13 @@ js-yaml@^4.1.0: dependencies: argparse "^2.0.1" +kotlin-web-helpers@2.0.0: + version "2.0.0" + resolved "https://mirrors.cloud.tencent.com/npm/kotlin-web-helpers/-/kotlin-web-helpers-2.0.0.tgz#b112096b273c1e733e0b86560998235c09a19286" + integrity sha512-xkVGl60Ygn/zuLkDPx+oHj7jeLR7hCvoNF99nhwXMn8a3ApB4lLiC9pk4ol4NHPjyoCbvQctBqvzUcp8pkqyWw== + dependencies: + format-util "^1.0.5" + locate-path@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" @@ -308,10 +315,10 @@ minimatch@^5.0.1, minimatch@^5.1.6: dependencies: brace-expansion "^2.0.1" -mocha@10.7.0: - version "10.7.0" - resolved "https://registry.npmmirror.com/mocha/-/mocha-10.7.0.tgz#9e5cbed8fa9b37537a25bd1f7fb4f6fc45458b9a" - integrity sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA== +mocha@10.7.3: + version "10.7.3" + resolved "https://mirrors.cloud.tencent.com/npm/mocha/-/mocha-10.7.3.tgz#ae32003cabbd52b59aece17846056a68eb4b0752" + integrity sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A== dependencies: ansi-colors "^4.1.3" browser-stdout "^1.3.1" diff --git a/simbot-api/build.gradle.kts b/simbot-api/build.gradle.kts index d97a7bce9..d53d6e2d1 100644 --- a/simbot-api/build.gradle.kts +++ b/simbot-api/build.gradle.kts @@ -31,8 +31,7 @@ import java.time.Instant plugins { kotlin("multiplatform") kotlin("plugin.serialization") -// id("io.gitlab.arturbosch.detekt") - id("simbot.suspend-transform-configure") + alias(libs.plugins.suspendTransform) alias(libs.plugins.ksp) id("simbot.dokka-module-configuration") id("com.github.gmazzo.buildconfig") diff --git a/simbot-extensions/simbot-extension-continuous-session/build.gradle.kts b/simbot-extensions/simbot-extension-continuous-session/build.gradle.kts index 40221d132..cd18f0b89 100644 --- a/simbot-extensions/simbot-extension-continuous-session/build.gradle.kts +++ b/simbot-extensions/simbot-extension-continuous-session/build.gradle.kts @@ -27,7 +27,7 @@ import love.forte.gradle.common.kotlin.multiplatform.applyTier3 plugins { kotlin("multiplatform") - id("simbot.suspend-transform-configure") + alias(libs.plugins.suspendTransform) id("simbot.dokka-module-configuration") } diff --git a/simbot-test/build.gradle.kts b/simbot-test/build.gradle.kts index 305d7de44..0d74f9324 100644 --- a/simbot-test/build.gradle.kts +++ b/simbot-test/build.gradle.kts @@ -29,8 +29,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi plugins { kotlin("multiplatform") kotlin("plugin.serialization") -// id("io.gitlab.arturbosch.detekt") - id("simbot.suspend-transform-configure") + alias(libs.plugins.suspendTransform) alias(libs.plugins.ksp) id("simbot.dokka-module-configuration") } diff --git a/website b/website index 9c602169c..834653217 160000 --- a/website +++ b/website @@ -1 +1 @@ -Subproject commit 9c602169ce00bf89dfd9d14c026b2ff9c276000e +Subproject commit 8346532172cee64a5466f56a6cfbb30df7281759