-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
build.gradle.kts
335 lines (273 loc) · 12.4 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.changelog.Changelog
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
fun properties(key: String) = project.findProperty(key).toString()
// Include the Gradle plugins which help building everything.
// Supersedes the use of "buildscript" block and "apply plugin:"
plugins {
id("org.jetbrains.intellij.platform") version "2.1.0"
kotlin("jvm") version ("2.0.20")
kotlin("plugin.serialization") version ("2.0.20")
// Plugin which can check for Gradle dependencies, use the help/dependencyUpdates task.
id("com.github.ben-manes.versions") version "0.51.0"
// Plugin which can update Gradle dependencies, use the help/useLatestVersions task.
id("se.patrikerdes.use-latest-versions") version "0.2.18"
// Used to debug in a different IDE
id("de.undercouch.download") version "5.6.0"
// Test coverage
id("org.jetbrains.kotlinx.kover") version "0.8.3"
// Linting
id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
// Vulnerability scanning
id("org.owasp.dependencycheck") version "10.0.4"
id("org.jetbrains.changelog") version "2.2.1"
id("org.jetbrains.grammarkit") version "2022.3.2.2"
}
group = "nl.hannahsten"
version = properties("pluginVersion")
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
maven("https://www.jetbrains.com/intellij-repository/snapshots")
}
}
sourceSets {
getByName("main").apply {
java.srcDirs("src", "gen")
resources.srcDirs("resources")
}
getByName("test").apply {
java.srcDirs("test")
resources.srcDirs("test/resources")
}
}
// Java target version
java.sourceCompatibility = JavaVersion.VERSION_21
// Specify the right jvm target for Kotlin
tasks.compileKotlin {
compilerOptions {
freeCompilerArgs = listOf("-Xjvm-default=all")
}
}
// Same for Kotlin tests
tasks.compileTestKotlin {
compilerOptions {
freeCompilerArgs = listOf("-Xjvm-default=all")
}
}
configurations {
all {
// https://stackoverflow.com/questions/11677572/dealing-with-xerces-hell-in-java-maven
exclude(group = "xml-apis")
exclude(group = "xerces")
// https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#coroutinesLibraries
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core")
}
}
dependencies {
intellijPlatform {
instrumentationTools()
zipSigner()
pluginVerifier()
testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.Plugin.Java)
intellijIdeaCommunity("2024.2.3")
// Docs: https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
// All snapshot versions: https://www.jetbrains.com/intellij-repository/snapshots/
// intellijIdeaCommunity("243.20847-EAP-CANDIDATE-SNAPSHOT", useInstaller = false)
// jetbrainsRuntime() // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#target-versions-multi-os-archives
// Example to use a different, locally installed, IDE
// If you get the error "Cannot find builtin plugin java for IDE", remove the "java" plugin above
// Also disable "version" above
// If it doesn't work (Could not resolve all files for configuration ':detachedConfiguration4'.), specify 'version' instead
// localPath.set("/home/thomas/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/213.6777.50/")
bundledPlugin("com.intellij.java")
bundledPlugin("tanvd.grazi")
plugin("com.firsttimeinforever.intellij.pdf.viewer.intellij-pdf-viewer:0.16.1")
plugin("com.jetbrains.hackathon.indices.viewer:1.27")
}
// Local dependencies
implementation(files("lib/pretty-tools-JDDE-2.1.0.jar"))
// These lines can sometimes be problematic on Linux, but are required for SumatraPDF
// TODO Temporarily disabled to fix Linux builds
// implementation(files("lib/JavaDDE.dll"))
// implementation(files("lib/JavaDDEx64.dll"))
// D-Bus Java bindings
implementation("com.github.hypfvieh:dbus-java-core:5.1.0")
implementation("com.github.hypfvieh:dbus-java-transport-native-unixsocket:5.1.0")
implementation("org.slf4j:slf4j-simple:2.0.16")
// Unzipping tar.xz/tar.bz2 files on Windows containing dtx files
implementation("org.codehaus.plexus:plexus-component-api:1.0-alpha-33")
implementation("org.codehaus.plexus:plexus-container-default:2.1.1")
implementation("org.codehaus.plexus:plexus-archiver:4.10.0")
// Parsing json
implementation("com.beust:klaxon:5.6")
// Parsing xml
implementation("com.fasterxml.jackson.core:jackson-core:2.18.0")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.0")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.1")
// Http requests
implementation("io.ktor:ktor-client-core:3.0.0")
implementation("io.ktor:ktor-client-cio:3.0.0")
implementation("io.ktor:ktor-client-auth:3.0.0")
implementation("io.ktor:ktor-client-content-negotiation:3.0.0")
implementation("io.ktor:ktor-server-core:3.0.0")
implementation("io.ktor:ktor-server-jetty-jakarta:3.0.0")
implementation("io.ktor:ktor-serialization-kotlinx-json:3.0.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
// Comparing versions
implementation("org.apache.maven:maven-artifact:4.0.0-beta-5")
// LaTeX rendering for preview
implementation("org.scilab.forge:jlatexmath:1.0.7")
implementation("org.apache.xmlgraphics:batik-all:1.18")
implementation("batik:batik-svg-dom:1.6-1")
implementation("io.arrow-kt:arrow-core:1.2.4")
implementation("io.arrow-kt:arrow-fx-coroutines:1.2.4")
implementation("io.arrow-kt:arrow-resilience:1.2.4")
// Test dependencies
// No version specified, it equals the kotlin version
testImplementation("org.jetbrains.kotlin:kotlin-test")
// Also implementation junit 4, just in case
testImplementation("junit:junit:4.13.2")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.11.3")
// Use junit 5 for test cases
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.3")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.1")
// Enable use of the JUnitPlatform Runner within the IDE
testImplementation("org.junit.platform:junit-platform-runner:1.11.2")
testImplementation("io.mockk:mockk:1.13.13")
// Add custom ruleset from github.com/slideclimb/ktlint-ruleset
ktlintRuleset(files("lib/ktlint-ruleset-0.2.jar"))
}
// Special resource dependencies
tasks.processResources {
from("lib") {
include("pretty-tools-JDDE-2.1.0.jar")
include("JavaDDE.dll")
include("JavaDDEx64.dll")
}
}
// Avoid ClassNotFoundException: com.maddyhome.idea.copyright.psi.UpdateCopyrightsProvider
tasks.buildSearchableOptions {
jvmArgs = listOf("-Djava.system.class.loader=com.intellij.util.lang.PathClassLoader")
}
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.set(listOf("Added", "Fixed"))
repositoryUrl.set("https://github.com/Hannah-Sten/TeXiFy-IDEA")
itemPrefix.set("*")
}
intellijPlatform {
pluginConfiguration {
name = "TeXiFy-IDEA"
// Get the latest available change notes from the changelog file
changeNotes = (
provider {
with(changelog) {
renderItem(
getOrNull(properties("pluginVersion")) ?: getLatest(),
Changelog.OutputType.HTML
)
}
}
)
ideaVersion {
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild = provider { null }
}
}
publishing {
// Allow publishing to the Jetbrains repo via a Gradle task
// This requires to put a Jetbrains Hub token, see http://www.jetbrains.org/intellij/sdk/docs/tutorials/build_system/deployment.html for more details
// Generate a Hub token at https://hub.jetbrains.com/users/me?tab=authentification
// You should provide it either via environment variables (ORG_GRADLE_PROJECT_intellijPublishToken) or Gradle task parameters (-Dorg.gradle.project.intellijPublishToken=mytoken)
token.set(properties["intellijPublishToken"].toString())
// Specify channel as per the tutorial.
// More documentation: https://github.com/JetBrains/gradle-intellij-plugin/blob/master/README.md#publishing-dsl
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "stable" }.split('.').first()))
}
}
// https://plugins.jetbrains.com/docs/intellij/dynamic-plugins.html#diagnosing-leaks
tasks.runIde {
jvmArgs = mutableListOf("-XX:+UnlockDiagnosticVMOptions", "-Xmx2g", "-Djava.system.class.loader=com.intellij.util.lang.PathClassLoader")
// Set to true to generate hprof files on unload fails
systemProperty("ide.plugins.snapshot.on.unload.fail", "false")
// Some warning asked for this to be set explicitly
systemProperty("idea.log.path", file("build/idea-sandbox/system/log").absolutePath)
}
tasks.test {
// For MockK. Make sure it finds the libattach.so in the lib folder.
jvmArgs = listOf("-Djdk.attach.allowAttachSelf=true", "-Djava.library.path=lib/")
// Enable JUnit 5 (Gradle 4.6+).
useJUnitPlatform()
// Show test results
testLogging {
events(TestLogEvent.FAILED, TestLogEvent.SKIPPED)
exceptionFormat = TestExceptionFormat.FULL
}
// https://intellij-support.jetbrains.com/hc/en-us/community/posts/4407334950290-jarFiles-is-not-set-for-PluginDescriptor
systemProperty("idea.force.use.core.classloader", "true")
}
ktlint {
verbose.set(true)
filter {
exclude { it.file.path.contains("generated") }
}
}
tasks.jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// https://github.com/ben-manes/gradle-versions-plugin
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
tasks.dependencyUpdates {
rejectVersionIf {
isNonStable(candidate.version)
}
}
tasks.useLatestVersions {
// Do not update this ktlint plugin, it is mostly unmaintained and newer versions are usually either broken or introduce unwanted style changes
updateBlacklist = listOf("org.jlleitschuh.gradle.ktlint")
}
tasks {
val generateLatexParserTask = register<GenerateParserTask>("generateLatexParser") {
sourceFile.set(File("src/nl/hannahsten/texifyidea/grammar/Latex.bnf"))
targetRootOutputDir.set(File("gen"))
pathToParser.set("nl/hannahsten/texifyidea/parser/LatexParser.java")
pathToPsiRoot.set("nl/hannahsten/texifyidea/psi")
}
val generateBibtexParserTask = register<GenerateParserTask>("generateBibtexParser") {
sourceFile.set(File("src/nl/hannahsten/texifyidea/grammar/Bibtex.bnf"))
targetRootOutputDir.set(File("gen"))
pathToParser.set("nl/hannahsten/texifyidea/parser/BibtexParser.java")
pathToPsiRoot.set("nl/hannahsten/texifyidea/psi")
}
val generateLatexLexerTask = register<GenerateLexerTask>("generateLatexLexer") {
sourceFile.set(File("src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex"))
targetOutputDir.set(File("gen/nl/hannahsten/texifyidea/grammar/"))
}
val generateBibtexLexerTask = register<GenerateLexerTask>("generateBibtexLexer") {
sourceFile.set(File("src/nl/hannahsten/texifyidea/grammar/BibtexLexer.flex"))
targetOutputDir.set(File("gen/nl/hannahsten/texifyidea/grammar/"))
}
initializeIntellijPlatformPlugin {
dependsOn(generateLatexParserTask)
dependsOn(generateBibtexParserTask)
dependsOn(generateLatexLexerTask)
dependsOn(generateBibtexLexerTask)
}
runKtlintCheckOverMainSourceSet {
dependsOn(initializeIntellijPlatformPlugin)
}
compileKotlin {
dependsOn(initializeIntellijPlatformPlugin)
}
}