-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
194 lines (178 loc) · 5.13 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import org.jetbrains.changelog.*
import org.jetbrains.kotlin.gradle.tasks.*
import org.jetbrains.kotlin.utils.*
plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.24"
id("org.jetbrains.kotlin.plugin.allopen") version "1.9.24"
id("org.jetbrains.intellij") version "1.17.3"
id("org.jetbrains.grammarkit") version "2022.3.2.2"
id("org.jetbrains.changelog") version "2.0.0"
}
group = providers.gradleProperty("pluginGroup").get()
version = providers.gradleProperty("pluginVersion").get()
intellij {
pluginName.set(providers.gradleProperty("pluginName"))
type.set(providers.gradleProperty("intellijType"))
version.set(providers.gradleProperty("intellijVersion"))
plugins.add("com.intellij.platform.images")
//optional
plugins.add("markdown")
plugins.add("uml")
plugins.add("cn.yiiguxing.plugin.translate:3.5.2") //https://github.com/YiiGuxing/TranslationPlugin
//reference
plugins.add("properties")
plugins.add("java")
plugins.add("org.jetbrains.kotlin")
}
grammarKit {
jflexRelease.set("1.7.0-2")
}
repositories {
mavenCentral()
maven("https://www.jetbrains.com/intellij-repository/releases")
}
dependencies {
//FROM DDS4J
implementation("ar.com.hjg:pngj:2.1.0")
//CSV
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.17.0") {
exclude(module = "jackson-annotations")
exclude(module = "jackson-core")
exclude(module = "jackson-databind")
}
////Sqlite
//implementation("org.xerial:sqlite-jdbc:3.40.1.0")
//Javassist
implementation("org.javassist:javassist:3.30.2-GA")
//JUnit
testImplementation("junit:junit:4.13.2")
//Sqlite
testImplementation("org.xerial:sqlite-jdbc:3.45.3.0")
//Byte Buddy
testImplementation("net.bytebuddy:byte-buddy:1.14.15")
testImplementation("net.bytebuddy:byte-buddy-agent:1.14.15")
//Javassist
testImplementation("org.javassist:javassist:3.30.2-GA")
////JOGL
//testImplementation("org.jogamp.jogl:jogl-all:2.3.2")
////OPENRNDR
//testImplementation("org.openrndr:openrndr-dds:0.4.4-alpha2")
}
sourceSets {
main {
java.srcDirs("src/main/java", "src/main/kotlin", "src/main/gen")
resources.srcDirs("src/main/resources")
}
test {
java.srcDirs("src/test/java", "src/test/kotlin")
resources.srcDirs("src/test/resources")
}
}
kotlin {
jvmToolchain(17)
}
allOpen {
annotation("icu.windea.pls.injectx.injectors.FileRenderCodeInjector")
}
val excludesInJar = listOf(
"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-vic2-config" to "vic3",
)
tasks {
withType<Copy> {
duplicatesStrategy = DuplicatesStrategy.INCLUDE //需要加上
}
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = listOf(
"-Xjvm-default=all",
"-Xinline-classes",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlin.ExperimentalStdlibApi",
)
}
}
withType<Test> {
useJUnitPlatform()
isScanForTestClasses = false
include("**/*Test.class")
}
withType<Jar> {
//排除特定文件
excludesInJar.forEach { exclude(it) }
//添加项目文档和许可证
from("README.md", "README_en.md", "LICENSE")
//添加CWT配置文件
cwtConfigDirs.forEach { (cwtConfigDir, toDir) ->
into("config/$toDir") {
from("$rootDir/cwt/$cwtConfigDir") {
includeEmptyDirs = false
include("**/*.cwt", "**/LICENSE", "**/*.md")
//打平config子目录中的文件
eachFile {
val i = path.indexOf("/config", ignoreCase = true)
if(i != -1) path = path.removeRange(i, i + 7)
}
}
}
}
into("config") {
from("cwt/README.md", "cwt/LICENSE")
}
}
patchPluginXml {
fun String.toChangeLogText(): String {
val regex1 = """[-*] \[ ].*""".toRegex()
val regex2 = """[-*] \[X].*""".toRegex(RegexOption.IGNORE_CASE)
return lines()
.run {
val start = indexOfFirst { it.startsWith("## ${version.get()}") }
val end = indexOfFirst(start + 1) { it.startsWith("## ") }.let { if(it != -1) it else size }
subList(start + 1, end)
}
.mapNotNull {
when {
it.contains("(HIDDEN)") -> null //hidden
it.matches(regex1) -> null //undo
it.matches(regex2) -> "*" + it.substring(5) //done
else -> it
}
}
.joinToString("\n")
.let { markdownToHTML(it) }
}
sinceBuild.set(providers.gradleProperty("sinceBuild"))
untilBuild.set(providers.gradleProperty("untilBuild"))
pluginDescription.set(projectDir.resolve("DESCRIPTION.md").readText())
changeNotes.set(projectDir.resolve("CHANGELOG.md").readText().toChangeLogText())
}
buildPlugin {
//排除特定文件
excludesInZip.forEach { exclude(it) }
//重命名插件包
archiveBaseName.set(providers.gradleProperty("pluginPackageName"))
}
runIde {
systemProperty("idea.is.internal", true)
systemProperty("pls.is.debug", true)
jvmArgs("-Xmx4G") //自定义JVM参数
}
publishPlugin {
token.set(providers.environmentVariable("IDEA_TOKEN"))
}
}