Skip to content

Commit

Permalink
将内置规则统一移到插件压缩包中的内置规则jar包中
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonKnightOfBreeze committed Jan 17, 2025
1 parent bf33b1d commit 8b62600
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 34 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
## 1.3.28

* [ ] 提供扩展点以更好地识别各种来源的游戏目录和模组目录(参见 #111
* [X] 将内置规则统一移到插件压缩包中的单独的jar包中
* [X] 其他优化与BUG修复

***

* [ ] Provides EP to better identify game directories and mod directories from various sources (See #111)
* [X] Move built-in configs into individual jar package which is inside which is inside the plugin's zip package
* [X] Other optimizations and bug fixes

## 1.3.27
Expand Down
74 changes: 43 additions & 31 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ fun String.toChangeLogText(): String {

intellijPlatform {
pluginConfiguration {
id.set(providers.gradleProperty("pluginId"))
name.set(providers.gradleProperty("pluginName"))
version.set(providers.gradleProperty("pluginVersion"))
description.set(projectDir.resolve("DESCRIPTION.md").readText())
changeNotes.set(projectDir.resolve("CHANGELOG.md").readText().toChangeLogText())
id = providers.gradleProperty("pluginId")
name = providers.gradleProperty("pluginName")
version = providers.gradleProperty("pluginVersion")
description = provider { projectDir.resolve("DESCRIPTION.md").readText() }
changeNotes = provider { projectDir.resolve("CHANGELOG.md").readText().toChangeLogText() }
ideaVersion {
sinceBuild.set(providers.gradleProperty("sinceBuild"))
untilBuild.set(provider { null })
sinceBuild = providers.gradleProperty("sinceBuild")
untilBuild = provider { null }
}
}
publishing {
token.set(providers.environmentVariable("IDEA_TOKEN"))
token = providers.environmentVariable("IDEA_TOKEN")
}
}

grammarKit {
jflexRelease.set("1.7.0-2")
jflexRelease = provider { "1.7.0-2" }
}

repositories {
Expand Down Expand Up @@ -125,22 +125,11 @@ kotlin {
}

val excludesInJar = listOf(
"icu/windea/pls/dev",
"icu/windea/pls/core/data/CsvExtensions*.class",
"icu/windea/pls/dev",
"icu/windea/pls/core/data/CsvExtensions*.class",
)
val excludesInZip = listOf(
"lib/jackson-dataformat-csv-*.jar",
)
val cwtConfigDirs = listOf(
"core" to "core",
"cwtools-ck2-config" to "ck2",
"cwtools-ck3-config" to "ck3",
"cwtools-eu4-config" to "eu4",
"cwtools-hoi4-config" to "hoi4",
"cwtools-ir-config" to "ir",
"cwtools-stellaris-config" to "stellaris",
"cwtools-vic2-config" to "vic2",
"cwtools-vic3-config" to "vic3",
"lib/jackson-dataformat-csv-*.jar",
)

tasks {
Expand All @@ -158,12 +147,23 @@ tasks {
)
}
}
jar {
//添加项目文档和许可证
from("README.md", "README_en.md", "LICENSE")
//排除特定文件
excludesInJar.forEach { exclude(it) }
//添加CWT规则文件
val configJar by register<Jar>("configJar") {
archiveBaseName = providers.gradleProperty("configPackageName")
archiveVersion = provider { "" }

val cwtConfigDirs = listOf(
"core" to "core",
"cwtools-ck2-config" to "ck2",
"cwtools-ck3-config" to "ck3",
"cwtools-eu4-config" to "eu4",
"cwtools-hoi4-config" to "hoi4",
"cwtools-ir-config" to "ir",
"cwtools-stellaris-config" to "stellaris",
"cwtools-vic2-config" to "vic2",
"cwtools-vic3-config" to "vic3",
)

//添加规则文件
cwtConfigDirs.forEach { (cwtConfigDir, toDir) ->
into("config/$toDir") {
from("$rootDir/cwt/$cwtConfigDir") {
Expand All @@ -172,24 +172,36 @@ tasks {
//打平config子目录中的文件
eachFile {
val i = path.indexOf("/config", ignoreCase = true)
if(i != -1) path = path.removeRange(i, i + 7)
if (i != -1) path = path.removeRange(i, i + 7)
}
}
}
}
//添加文档和许可证
into("config") {
from("cwt/README.md", "cwt/LICENSE")
}
}
jar {
dependsOn(configJar)

//添加项目文档和许可证
from("README.md", "README_en.md", "LICENSE")
//排除特定文件
excludesInJar.forEach { exclude(it) }
}
instrumentedJar {
//排除特定文件
excludesInJar.forEach { exclude(it) }
}
buildPlugin {
into("lib") {
from(configJar.outputs.files.singleFile)
}
//排除特定文件
excludesInZip.forEach { exclude(it) }
//重命名插件包
archiveBaseName.set(providers.gradleProperty("pluginPackageName"))
archiveBaseName = providers.gradleProperty("pluginPackageName")
}
runIde {
jvmArgumentProviders += CommandLineArgumentProvider {
Expand Down
2 changes: 1 addition & 1 deletion docs/en/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Reference Links:

#### Built-in Config Groups {#builtin-config-groups}

* Path: `config/{gameType}`[^1] (in the plugin jar)
* Path: `config/{gameType}`[^1] (in the built-in configs jar, which is inside the plugin's zip package)
* Enabled: Always
* Customizable :No

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PLS基于由CWT规则文件组成的规则分组,实现了诸多语言功能

#### 内置的规则分组 {#builtin-config-groups}

* 路径:`config/{gameType}`[^1]位于插件jar包中
* 路径:`config/{gameType}`[^1]位于插件压缩包中的内置规则jar包中
* 是否启用:始终启用
* 是否可自定义:否

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pluginVersion=1.3.28
platformType=IU
platformVersion=2024.2
sinceBuild=242
configPackageName=builtin-configs

# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
kotlin.stdlib.default.dependency=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class CwtConfigGroupFileProviderBase : CwtConfigGroupFileProvider {
/**
* 用于提供插件内置的规则分组。
*
* 对应的路径:`config/${gameType}`(位于插件jar包中
* 对应的路径:`config/${gameType}`(位于插件压缩包中的内置规则jar包中
*/
class BuiltInCwtConfigGroupFileProvider : CwtConfigGroupFileProviderBase() {
private val rootDirectory by lazy { doGetRootDirectory() }
Expand Down

0 comments on commit 8b62600

Please sign in to comment.