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

Update Kotlin to v2.1.0; Update simbot to v4.9.0; Update kcp: KSP and kotlin-suspend-transform #151

Merged
merged 2 commits into from
Dec 4, 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
32 changes: 1 addition & 31 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
needs: run-test
# 交叉编译 support
# see https://kotlinlang.org/docs/multiplatform-publish-lib.html#host-requirements
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
# 检出仓库代码
- uses: actions/checkout@v4
Expand Down Expand Up @@ -111,36 +111,6 @@ jobs:
generate_release_notes: true
prerelease: ${{ contains(github.ref_name, 'preview') || contains(github.ref_name, 'alpha') }}

publish-snapshots:
name: Publish snapshots
# 交叉编译 support
# see https://kotlinlang.org/docs/multiplatform-publish-lib.html#host-requirements
runs-on: macos-latest
needs: publish-releases
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}

# setup Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: ${{ env.GRADLE_VERSION }}
arguments: |
publishToSonatype
closeAndReleaseStagingRepositories
--info
--warning-mode all
-x test
--build-cache
-Porg.gradle.jvmargs="-Xmx8g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
env:
SIMBOT_IS_SNAPSHOT: true
SIMBOT_SNAPSHOT_ONLY: true

deploy-doc:
name: Deploy KDoc
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
publish-snapshots:
name: Publish snapshots
needs: run-test
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- dev/main
- master
- main

jobs:
qodana:
if: ${{ !startsWith(github.head_ref, 'dependabot/') }}
Expand All @@ -22,10 +22,10 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@main
uses: JetBrains/qodana-action@v2024.2
with:
upload-result: true
github-token: ${{ secrets.FORLIY_ACCESS_TOKEN }}
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} # read the steps about it below
GITHUB_TOKEN: ${{ secrets.FORLIY_ACCESS_TOKEN }}
# GITHUB_TOKEN: ${{ secrets.FORLIY_ACCESS_TOKEN }}
23 changes: 20 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import io.gitlab.arturbosch.detekt.Detekt
import love.forte.gradle.common.core.project.setup
import love.forte.gradle.common.core.repository.Repositories
import love.forte.plugin.suspendtrans.gradle.SuspendTransformGradleExtension
import love.forte.simbot.gradle.suspendtransforms.addSimbotJvmTransformers
import util.isCi

plugins {
Expand All @@ -28,14 +30,16 @@ plugins {

alias(libs.plugins.detekt)
alias(libs.plugins.kotlinxBinaryCompatibilityValidator)
alias(libs.plugins.suspendTransform) apply false
}

setup(P.ComponentOneBot)

buildscript {
repositories {
mavenCentral()
mavenLocal()
dependencies {
// suspend-transform-gradle = { module = "love.forte.plugin.suspend-transform:suspend-transform-plugin-gradle", version.ref = "suspendTransform" }
classpath(libs.simbot.gradle)
// classpath("love.forte.plugin.suspend-transform:suspend-transform-plugin-gradle:4.9.0")
}
}

Expand All @@ -56,6 +60,19 @@ allprojects {
}
}

subprojects {
afterEvaluate {
if (plugins.hasPlugin(libs.plugins.suspendTransform.get().pluginId)) {
extensions.configure<SuspendTransformGradleExtension>("suspendTransform") {
includeRuntime = false
includeAnnotation = false

addSimbotJvmTransformers()
}
}
}
}

idea {
module.apply {
isDownloadSources = true
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ dependencies {
implementation("io.github.gradle-nexus:publish-plugin:2.0.0")

// simbot suspend transform gradle common
implementation(libs.simbot.gradle)
// compileOnly(libs.simbot.gradle)

// suspend transform
implementation(libs.suspend.transform.gradle)
// implementation(libs.suspend.transform.gradle)

// gradle common
implementation(libs.bundles.gradle.common)
Expand Down
88 changes: 2 additions & 86 deletions buildSrc/src/main/kotlin/JsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,96 +15,12 @@
* If not, see <https://www.gnu.org/licenses/>.
*/

import org.gradle.api.Project
import org.gradle.kotlin.dsl.the
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinWasmJsTargetDsl
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension


inline fun KotlinJsTargetDsl.configJs(
nodeJs: Boolean = true,
browser: Boolean = true,
block: () -> Unit = {}
) {
if (nodeJs) {
nodejs()
// {
//// testTask {
//// useMocha {
//// timeout = "10000"
//// }
//// }
// }
}

if (browser) {
browser()
// {
// testTask{
// useKarma {
// useChromeHeadless()
// // useConfigDirectory(File(project.rootProject.projectDir, "karma"))
// }
// }
// }
}

binaries.library()
block()
}


fun Project.configJsTestTasks() {
// val shouldRunJsBrowserTest = !hasProperty("teamcity") || hasProperty("enable-js-tests")
// if (shouldRunJsBrowserTest) return
tasks.findByName("cleanJsBrowserTest")?.apply {
onlyIf { false }
}
tasks.findByName("jsBrowserTest")?.apply {
onlyIf { false }
}
}

inline fun KotlinWasmJsTargetDsl.configWasmJs(
nodeJs: Boolean = true,
browser: Boolean = true,
block: () -> Unit = {}
) {
if (nodeJs && isLinux) {
// win in candy node `21.0.0-v8-canary202309143a48826a08` is not supported
// nodejs()
}

if (browser) {
browser {
testTask{
useKarma {
useChromeHeadless()
// useConfigDirectory(File(project.rootProject.projectDir, "karma"))
}
}
}
}

fun KotlinJsTargetDsl.configJs() {
nodejs()
binaries.library()
block()
}

inline fun Project.configWasmJsTest(block: () -> Unit = {}) {
if (false) {
// see https://youtrack.jetbrains.com/issue/KT-63014/Running-tests-with-wasmJs-in-1.9.20-requires-Chrome-Canary#focus=Comments-27-8321383.0-0
rootProject.the<NodeJsRootExtension>().apply {
// nodeVersion = "21.0.0-v8-canary202309143a48826a08"
version = "21.0.0-v8-canary202309143a48826a08"
downloadBaseUrl = "https://nodejs.org/download/v8-canary"
}

tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {
args.add("--ignore-engines")
}
}

block()
}
16 changes: 7 additions & 9 deletions buildSrc/src/main/kotlin/JvmConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@
import org.gradle.api.Project
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.kotlin.dsl.assign
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(jdkVersion: Int, crossinline block: KotlinJvmTarget.() -> Unit = {}) {
withJava()
compilerOptions {
Expand All @@ -50,8 +47,7 @@ inline fun KotlinJvmTarget.configJava(jdkVersion: Int, crossinline block: Kotlin
block()
}


fun KotlinTopLevelExtension.configJavaToolchain(jdkVersion: Int) {
fun KotlinBaseExtension.configJavaToolchain(jdkVersion: Int) {
jvmToolchain(jdkVersion)
}

Expand All @@ -71,10 +67,12 @@ inline fun KotlinJvmProjectExtension.configKotlinJvm(
) {
configJavaToolchain(jdkVersion)
compilerOptions {
javaParameters = true
javaParameters.set(true)
jvmTarget.set(JvmTarget.fromTarget(jdkVersion.toString()))
// freeCompilerArgs.addAll("-Xjvm-default=all", "-Xjsr305=strict")
freeCompilerArgs.set(freeCompilerArgs.getOrElse(emptyList()) + listOf("-Xjvm-default=all", "-Xjsr305=strict"))
freeCompilerArgs.addAll(
"-Xjvm-default=all",
"-Xjsr305=strict"
)
}
block()
}
Expand Down
6 changes: 2 additions & 4 deletions buildSrc/src/main/kotlin/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ object P {
override val description: String get() = DESCRIPTION
override val homepage: String get() = HOMEPAGE

const val VERSION = "1.4.5"
const val NEXT_VERSION = "1.4.6"
const val VERSION = "1.5.0"
const val NEXT_VERSION = "1.5.0"

override val snapshotVersion = "$NEXT_VERSION-SNAPSHOT"
override val version = if (isSnapshot()) snapshotVersion else VERSION
Expand Down Expand Up @@ -91,5 +91,3 @@ private fun initIsSnapshot(): Boolean {
fun isSnapshot(): Boolean = _isSnapshot

fun isSimbotLocal(): Boolean = systemProp("SIMBOT_LOCAL").toBoolean()

val isLinux: Boolean = systemProp("os.name")?.contains("linux", true) ?: false

This file was deleted.

8 changes: 7 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ kotlin.js.generate.executable.default=false

# Such dependencies are not applicable for Kotlin/Native, consider changing the dependency type to 'implementation' or 'api'.
# To disable this warning, set the kotlin.native.ignoreIncorrectDependencies=true project property
kotlin.native.ignoreIncorrectDependencies=true
#
# 2024/12/04 Update: w: The `kotlin.native.ignoreIncorrectDependencies` deprecated property is used in your build.
# Please, stop using it as it is unsupported and may apply no effect to your build.
# kotlin.native.ignoreIncorrectDependencies=true

# 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta. You can use -Xexpect-actual-classes flag to suppress this warning. Also see: https://youtrack.jetbrains.com/issue/KT-61573
# "-Xexpect-actual-classes"
Expand All @@ -27,3 +30,6 @@ org.gradle.caching=true
## > null cannot be cast to non-null type org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
## https://github.com/google/ksp/issues/1929
ksp.useKSP2=false

# https://kotlinlang.org/docs/multiplatform-publish-lib.html#host-requirements
kotlin.native.enableKlibsCrossCompilation=true
Loading
Loading