From 85ff3227c1aba424816e547786d7f41ef691e880 Mon Sep 17 00:00:00 2001 From: Him188 Date: Mon, 23 Sep 2024 13:50:12 +0100 Subject: [PATCH] Add intellij-annotations module for Language --- app/shared/app-data/build.gradle.kts | 1 + app/shared/build.gradle.kts | 1 + settings.gradle.kts | 18 ++++---------- utils/intellij-annotations/build.gradle.kts | 24 +++++++++++++++++++ .../src/commonMain/kotlin/Language.kt | 22 +++++++++++++++++ 5 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 utils/intellij-annotations/build.gradle.kts create mode 100644 utils/intellij-annotations/src/commonMain/kotlin/Language.kt diff --git a/app/shared/app-data/build.gradle.kts b/app/shared/app-data/build.gradle.kts index c3b453c804..57a77fc561 100644 --- a/app/shared/app-data/build.gradle.kts +++ b/app/shared/app-data/build.gradle.kts @@ -25,6 +25,7 @@ plugins { kotlin { sourceSets.commonMain.dependencies { implementation(projects.app.shared.appPlatform) + implementation(projects.utils.intellijAnnotations) api(projects.app.shared.videoPlayer.videoPlayerApi) api(projects.app.shared.videoPlayer.torrentSource) api(libs.kotlinx.coroutines.core) diff --git a/app/shared/build.gradle.kts b/app/shared/build.gradle.kts index 6ac026bcce..c72faada8f 100644 --- a/app/shared/build.gradle.kts +++ b/app/shared/build.gradle.kts @@ -50,6 +50,7 @@ kotlin { sourceSets.commonMain.dependencies { api(projects.utils.platform) + api(projects.utils.intellijAnnotations) api(libs.kotlinx.coroutines.core) api(libs.kotlinx.serialization.json) api(libs.kotlinx.serialization.json.io) diff --git a/settings.gradle.kts b/settings.gradle.kts index 2b1277bdce..57243a1fa9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,19 +1,10 @@ /* - * Ani - * Copyright (C) 2022-2024 Him188 + * Copyright (C) 2024 OpenAni and contributors. * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link. * - * 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 - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * https://github.com/open-ani/ani/blob/main/LICENSE */ rootProject.name = "ani" @@ -38,6 +29,7 @@ fun includeProject(projectPath: String, dir: String? = null) { // Utilities shared by client and server (targeting JVM) includeProject(":utils:platform") // 适配各个平台的基础 API +includeProject(":utils:intellij-annotations") includeProject(":utils:logging") // shared by client and server (targets JVM) includeProject(":utils:serialization", "utils/serialization") includeProject(":utils:coroutines", "utils/coroutines") diff --git a/utils/intellij-annotations/build.gradle.kts b/utils/intellij-annotations/build.gradle.kts new file mode 100644 index 0000000000..5e820cfa5a --- /dev/null +++ b/utils/intellij-annotations/build.gradle.kts @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2024 OpenAni and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link. + * + * https://github.com/open-ani/ani/blob/main/LICENSE + */ + +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi + +plugins { + kotlin("multiplatform") + `ani-mpp-lib-targets` +} + +kotlin { + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes") + + sourceSets.getByName("jvmMain").dependencies { + api(libs.jetbrains.annotations) + } +} diff --git a/utils/intellij-annotations/src/commonMain/kotlin/Language.kt b/utils/intellij-annotations/src/commonMain/kotlin/Language.kt new file mode 100644 index 0000000000..4002ef0cac --- /dev/null +++ b/utils/intellij-annotations/src/commonMain/kotlin/Language.kt @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 OpenAni and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link. + * + * https://github.com/open-ani/ani/blob/main/LICENSE + */ + +package org.intellij.lang.annotations // 必须和 IJ 相同 + +/** + * @sample org.intellij.lang.annotations.Language + */ +@OptIn(ExperimentalMultiplatform::class) +@Retention(AnnotationRetention.SOURCE) // 我们不分发, 有 SOURCE 就够了 +@OptionalExpectation +expect annotation class Language( + val value: String, + val prefix: String = "", + val suffix: String = "" +) // no actual on any platform. 实际上 JVM 有这个类, 所以如果这里 JVM actual, 会有冲突