generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
216 lines (182 loc) · 5.94 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import org.gradle.api.JavaVersion.VERSION_17
import org.jetbrains.changelog.Changelog
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformDependenciesExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
fun properties(key: String) = providers.gradleProperty(key)
fun prop(name: String): String =
extra.properties[name] as? String ?: error("Property `$name` is not defined in gradle.properties")
plugins {
idea
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "2.0.21"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij.platform") version "2.1.0"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "2.2.1"
// Gradle Qodana Plugin
id("org.jetbrains.qodana") version "2024.2.3"
id("org.jetbrains.grammarkit") version "2022.3.2.2"
}
kotlin {
jvmToolchain(17)
}
// Configure project's dependencies
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}
intellijPlatform {
instrumentCode = true
buildSearchableOptions = false
pluginConfiguration {
id = prop("pluginGroup")
name = prop("pluginName")
version = prop("pluginVersion")
vendor {
name = "Phodal Huang"
}
ideaVersion {
sinceBuild = prop("pluginSinceBuild")
untilBuild = prop("pluginUntilBuild")
}
}
}
dependencies {
testImplementation("junit:junit:4.13.2")
intellijPlatform {
intellijIde(prop("ideaVersion"))
instrumentationTools()
pluginVerifier()
testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.Bundled)
}
}
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
version.set(properties("pluginVersion"))
groups.empty()
path.set(rootProject.file("CHANGELOG.md").toString())
repositoryUrl.set(properties("pluginRepositoryUrl"))
itemPrefix.set("*")
}
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
version.set(properties("pluginVersion"))
groups.set(emptyList())
path.set(rootProject.file("CHANGELOG.md").toString())
repositoryUrl.set(properties("pluginRepositoryUrl"))
}
idea {
module {
generatedSourceDirs.add(file("src/gen"))
isDownloadJavadoc = true
isDownloadSources = true
}
}
sourceSets {
main {
java.srcDirs("src", "src/gen")
}
test {
resources.srcDirs("src/test/resources")
}
}
kotlin {
sourceSets {
main {
kotlin.srcDirs("src/main/kotlin")
}
test {
kotlin.srcDirs("src/test/kotlin")
}
}
}
intellijPlatformTesting {
runIde {
register("runIdeForUiTests") {
task {
jvmArgumentProviders += CommandLineArgumentProvider {
listOf(
"-Drobot-server.port=8082",
"-Dide.mac.message.dialogs.as.sheets=false",
"-Djb.privacy.policy.text=<!--999.999-->",
"-Djb.consents.confirmation.enabled=false",
)
}
}
plugins {
robotServerPlugin()
}
}
}
}
tasks {
generateLexer {
sourceFile.set(file("src/main/grammars/FeakinLexer.flex"))
targetOutputDir.set(file("src/gen/com/feakin/intellij/lexer"))
purgeOldFiles.set(true)
}
generateParser {
sourceFile.set(file("src/main/grammars/FeakinParser.bnf"))
targetRootOutputDir.set(file("src/gen"))
pathToParser.set("com/feakin/intellij/parser/FeakinParser.java")
pathToPsiRoot.set("com/feakin/intellij/psi")
purgeOldFiles.set(true)
}
withType<KotlinCompile> {
dependsOn(generateLexer, generateParser)
}
patchPluginXml {
pluginDescription.set(provider { file("src/description.html").readText() })
changelog {
version.set(prop("pluginVersion"))
groups.empty()
path.set(rootProject.file("CHANGELOG.md").toString())
repositoryUrl.set(prop("pluginRepositoryUrl"))
}
val changelog = project.changelog
// 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,
)
}
})
}
signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}
val newName = "intellij-feakin-" + prop("ideaVersion") + "-" + prop("pluginVersion")
buildPlugin {
archiveBaseName.convention(newName)
}
publishPlugin {
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN"))
channels.set(properties("pluginVersion").map {
listOf(it.split('-').getOrElse(1) { "default" }.split('.').first())
})
}
}
fun IntelliJPlatformDependenciesExtension.intellijIde(versionWithCode: String) {
val (type, version) = versionWithCode.toTypeWithVersion()
create(type, version, useInstaller = false)
}
data class TypeWithVersion(val type: IntelliJPlatformType, val version: String)
fun String.toTypeWithVersion(): TypeWithVersion {
val (code, version) = split("-", limit = 2)
return TypeWithVersion(IntelliJPlatformType.fromCode(code), version)
}