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

尝试启用 K2 编译器 #753

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .idea/runConfigurations/_allTests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ subprojects {
if (hasKtP()) {
// apply(plugin = "io.gitlab.arturbosch.detekt")
applyDetekt()
if ("gradle" !in name) {
useK2()
logger.info("Enable K2 for {}", this)
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,15 @@ idea {
isDownloadSources = true
}
}

// tasks.withType(KotlinCompile::class.java).configureEach {
// kotlinOptions.languageVersion = "1.9"
// }

// val compileKotlin: KotlinCompile by tasks
// compileKotlin.kotlinOptions.freeCompilerArgs += listOf(
// "-Xjvm-default=all",
// // "-opt-in=kotlin.RequiresOptIn",
// // see https://youtrack.jetbrains.com/issue/KTIJ-21563
// "-Xskip-prerelease-check",
// )
35 changes: 35 additions & 0 deletions buildSrc/src/main/kotlin/K2Config.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2024. ForteScarlet.
*
* Project https://github.com/simple-robot/simpler-robot
* Email [email protected]
*
* 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 <https://www.gnu.org/licenses/>.
*
*/

import org.gradle.api.Project
import org.gradle.kotlin.dsl.withType


fun Project.useK2(languageVersion: String = "2.0") {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
// useK2
this.languageVersion = languageVersion
}
}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ sealed class P(override val group: String) : ProjectDetail() {
val versionWithoutSnapshot: Version

init {
val mainVersion = version(4, 0, 0) - version("dev14")
val mainVersion = version(4, 0, 0) - version("dev15")

fun initVersionWithoutSnapshot(status: Version?): Version = if (status == null) {
mainVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import java.time.Year


/*
使用在根配置,配置dokka多模块
使用在根配置,配置dokka多模块
*/

plugins {
Expand Down
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ spring-boot-v3 = "3.2.1"
openjdk-jmh = "1.36"
ktor = "2.3.7"
slf4j = "2.0.7"
ksp = "1.9.22-1.0.16"
#ksp = "1.9.22-1.0.16"
ksp = "1.9.22-1.0.17"
# https://square.github.io/kotlinpoet/
kotlinPoet = "1.15.3"
reactor = "3.6.2"
#
suspendTransform = "0.6.0"
suspendTransform = "0.7.0-beta1"
suspendReversal = "0.2.0"
gradleCommon = "0.2.0"

Expand Down
1 change: 1 addition & 0 deletions simbot-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ kotlin {
implementation(libs.ktor.client.core)

implementation(kotlin("test-junit5"))
implementation(kotlin("reflect"))
implementation(libs.ktor.client.cio)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public fun interface JBlockingApplicationLauncher<out A : Application> {
}

private class JBlockingApplicationLauncherImpl<out A : Application>(
private val handler: JBlockingApplicationLauncher<A>,
// TODO private:
// e: file:///G:/code/simbot/simbot-api/src/jvmMain/kotlin/love/forte/simbot/application/ApplicationFactory.jvm.kt:78:35 Cannot access 'val handler: JBlockingApplicationLauncher<Application>': it is private/*private to this*/ in 'love/forte/simbot/application/JBlockingApplicationLauncherImpl'
val handler: JBlockingApplicationLauncher<A>,
private val handlerContext: CoroutineContext
) : ApplicationLauncher<A> {
override suspend fun launch(): A {
Expand All @@ -73,8 +75,8 @@ private class JBlockingApplicationLauncherImpl<out A : Application>(
if (this === other) return true
if (other !is JBlockingApplicationLauncherImpl<*>) return false

if (handler != other.handler) return false
if (handlerContext != other.handlerContext) return false
if (this.handler != other.handler) return false

return true
}
Expand Down
Loading
Loading