-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
117 lines (102 loc) · 3.81 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
117 lines (102 loc) · 3.81 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
plugins {
id("java")
alias(libs.plugins.kotlin)
alias(libs.plugins.intelliJPlatform)
}
group = providers.gradleProperty("pluginGroup").get()
version = providers.gradleProperty("pluginVersion").get()
kotlin { jvmToolchain(21) }
repositories {
mavenCentral()
intellijPlatform { defaultRepositories() }
}
dependencies {
intellijPlatform {
create(
providers.gradleProperty("platformType"),
providers.gradleProperty("platformVersion"),
)
pluginVerifier()
}
}
intellijPlatform {
pluginConfiguration {
version = providers.gradleProperty("pluginVersion")
// What the Marketplace shows as "What's new": the section of
// CHANGELOG.md that carries the version being built. Rendered while the
// build configures - a provider would have to carry a reference to this
// script, which the configuration cache cannot store.
changeNotes = changeNotesFor(
providers.fileContents(layout.projectDirectory.file("CHANGELOG.md")).asText.get(),
providers.gradleProperty("pluginVersion").get(),
)
ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild")
untilBuild = provider { null }
}
}
publishing {
// Marketplace token, from https://plugins.jetbrains.com/author/me/tokens
token = providers.environmentVariable("PUBLISH_TOKEN")
}
pluginVerification {
ides {
// Lower bound of the supported range.
create(IntelliJPlatformType.IntellijIdeaCommunity, "2025.1")
// Optionally an IDE installed on this machine - see gradle.properties.
providers.gradleProperty("verifyAgainstLocalIde").orNull
?.takeIf { file(it).isDirectory }
?.let(::local)
}
}
}
tasks {
wrapper { gradleVersion = "9.3.1" }
}
/**
* Renders the `## [version]` section of a Keep a Changelog file as the HTML the
* Marketplace expects. Everything below a `### Group` heading becomes one list,
* unknown lines are passed through as paragraphs.
*
* Hand-rolled rather than pulling in the Gradle changelog plugin: that one
* reaches back into the project from inside the task input, which the
* configuration cache rejects.
*/
fun changeNotesFor(markdown: String, version: String): String {
val lines = markdown.lineSequence().toList()
val start = lines.indexOfFirst { it.startsWith("## [$version]") }
if (start < 0) return ""
val body = lines.drop(start + 1).takeWhile { !it.startsWith("## ") }
val html = StringBuilder()
var inList = false
fun closeList() {
if (inList) html.append("</ul>")
inList = false
}
for (line in body) {
val text = line.trim()
when {
text.isEmpty() -> Unit
text.startsWith("### ") -> {
closeList()
html.append("<b>").append(inline(text.removePrefix("### "))).append("</b>")
}
text.startsWith("- ") -> {
if (!inList) html.append("<ul>")
inList = true
html.append("<li>").append(inline(text.removePrefix("- "))).append("</li>")
}
// Wrapped continuation of the entry above.
inList -> html.insert(html.length - "</li>".length, " " + inline(text))
else -> html.append("<p>").append(inline(text)).append("</p>")
}
}
closeList()
return html.toString()
}
/** Escapes HTML and turns `code spans` into <code> elements. */
fun inline(text: String): String {
val escaped = text.replace("&", "&").replace("<", "<").replace(">", ">")
return Regex("`([^`]+)`").replace(escaped) { "<code>" + it.groupValues[1] + "</code>" }
}