-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle.kts
138 lines (117 loc) · 4.58 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
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)
plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.0"
id("org.jetbrains.intellij") version "1.17.0"
id("org.jetbrains.changelog") version "2.1.0"
id("antlr")
}
group = properties("pluginGroup").get()
version = properties("pluginVersion").get()
repositories {
mavenCentral()
}
val antlrVersion = "4.12.0"
dependencies {
implementation("org.antlr:antlr4-intellij-adaptor:0.1") {
constraints {
implementation("org.antlr", "antlr4-runtime", antlrVersion) {
because("Old runtime leads to 'Could not deserialize ATN' error.")
}
}
}
antlr("org.antlr", "antlr4", antlrVersion) {
// Not required for 'generateGrammarSource' task.
exclude("com.ibm.icu", "icu4j")
exclude("org.abego.treelayout", "org.abego.treelayout.core")
}
}
//TODO: a hack to exclude antlr4 dependencies from the resulting distribution zip. See https://github.com/gradle/gradle/issues/820
configurations[JavaPlugin.API_CONFIGURATION_NAME].let { apiConfiguration ->
apiConfiguration.setExtendsFrom(apiConfiguration.extendsFrom.filter { it.name != "antlr" })
}
kotlin {
jvmToolchain(11)
}
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
updateSinceUntilBuild.set(false)
}
changelog {
groups.empty()
repositoryUrl.set(properties("pluginRepositoryUrl"))
// Allow both d.d and d.d.d version formats.
headerParserRegex.set("""(\d+\.\d+(.\d+)?)""".toRegex())
}
tasks {
compileKotlin {
dependsOn(generateGrammarSource)
}
buildSearchableOptions {
enabled = false
}
patchPluginXml {
version.set(properties("pluginVersion"))
sinceBuild.set(properties("pluginSinceBuild"))
// untilBuild = properties("pluginUntilBuild")
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"
with (it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
} +
"<br>" +
"<a href=\"https://github.com/ris58h/WebCalm\">Source Code</a>" +
"<br>" +
"<a href=\"https://github.com/ris58h/WebCalm/issues\">Issue Tracker</a>"
})
val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes.set(properties("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
})
}
// A long releases list leads to `No space left on device` error while performing `build` GitHub action.
// So we shrink the list to verify just against the since and the latest versions.
val shrinkProductsReleases = register("shrinkProductsReleases") {
doLast {
val file = listProductsReleases.get().outputs.files.singleFile
val lines = file.readLines()
if (lines.size > 2) {
val shrunkLines = listOf(lines.first(), lines.last())
file.writeText(shrunkLines.joinToString("\n"))
}
}
}
listProductsReleases {
finalizedBy(shrinkProductsReleases)
}
signPlugin {
certificateChain.set(environment("CERTIFICATE_CHAIN"))
privateKey.set(environment("PRIVATE_KEY"))
password.set(environment("PRIVATE_KEY_PASSWORD"))
}
publishPlugin {
dependsOn(patchChangelog)
token.set(environment("PUBLISH_TOKEN"))
}
// TODO: a hack for an JBR issue. See https://youtrack.jetbrains.com/issue/IJSDK-1592
runIde {
jbrArch.set("x64")
}
}