-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
102 lines (87 loc) · 2.79 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
102 lines (87 loc) · 2.79 KB
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
import io.pebbletemplates.pebble.PebbleEngine
import io.pebbletemplates.pebble.loader.FileLoader
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath(libs.pebble)
}
}
plugins {
id("org.jetbrains.kotlin.jvm")
id("org.jetbrains.intellij.platform")
id("org.jetbrains.changelog")
}
dependencies {
intellijPlatform {
intellijIdea("2025.2.6.2")
bundledPlugins("com.intellij.java", "org.jetbrains.kotlin", "org.jetbrains.plugins.yaml")
plugins(
"com.cursiveclojure.cursive:2025.2-252",
"com.jetbrains.rust:252.27397.133",
"JavaScript:252.27397.106",
"org.intellij.scala:2025.2.30",
"org.jetbrains.plugins.go:252.26830.24",
"PsiViewer:252.23892.248",
"PythonCore:252.27397.103"
)
testFramework(TestFrameworkType.Platform)
}
}
intellijPlatform {
buildSearchableOptions = false
pluginConfiguration {
ideaVersion {
sinceBuild = "231"
}
}
}
tasks.register("generate") {
notCompatibleWithConfigurationCache("Pebble classes are not serializable")
description = "Generates theme and scheme files from pebble templates"
inputs.dir("src/main/templates")
outputs.dir("src/main/resources/themes")
doLast {
val engine = PebbleEngine.Builder()
.strictVariables(true)
.loader(FileLoader(file("src/main/templates/").absolutePath).apply { suffix = ".pebble" })
.build()
val themeTemplate = engine.getTemplate("theme")
val schemeTemplate = engine.getTemplate("alabaster")
val themesDir = file("src/main/resources/themes")
if (!themesDir.exists()) {
themesDir.mkdirs()
}
listOf("bg", "dark", "mono", "mono-dark", "").forEach { variant ->
val nameSuffix = when (variant) {
"" -> ""
"bg" -> " BG"
else -> variant.split('-').joinToString(" ", prefix = " ") { word -> word.replaceFirstChar { it.titlecaseChar() } }
}
val fileSuffix = if (variant.isEmpty()) variant else "-$variant"
val background = when (variant) {
"" -> "F7F7F7"
"bg", "mono" -> "FFFFFF"
"mono-dark" -> "111111"
"dark" -> "0E1415"
else -> throw IllegalArgumentException("Unknown variant: $variant")
}
val context = mapOf("variant" to variant, "name_suffix" to nameSuffix, "file_suffix" to fileSuffix, "primary_background" to background)
file("src/main/resources/themes/alabaster$fileSuffix.xml").writer().use { schemeTemplate.evaluate(it, context) }
file("src/main/resources/themes/alabaster$fileSuffix.theme.json").writer().use { themeTemplate.evaluate(it, context) }
}
}
}
tasks {
clean {
delete("src/main/resources/themes")
}
processResources {
dependsOn("generate")
}
wrapper {
gradleVersion = "9.5.0"
}
}