generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
205 lines (180 loc) · 6.49 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
import org.aya.gradle.BuildUtil
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.*
fun properties(key: String) = providers.gradleProperty(key)
var deps: Properties by rootProject.ext
deps = Properties()
file("gradle/deps.properties").reader().use(deps::load)
val javaVersion = properties("javaVersion").get().toInt()
val ayaVersion = deps.getProperty("version.aya").toString()
plugins {
// Java support
java
// Kotlin support
kotlin("jvm") version "2.1.0"
// https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij.platform") version "2.1.0"
// https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "2.2.1"
// https://github.com/JetBrains/gradle-grammar-kit-plugin
id("org.jetbrains.grammarkit") version "2022.3.2.2"
}
group = properties("pluginGroup")
version = deps.getProperty("version.project")
// Configure project's dependencies
repositories {
mavenLocal()
mavenCentral()
if (ayaVersion.endsWith("SNAPSHOT")) {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
intellijPlatform.defaultRepositories()
}
intellijPlatform.pluginConfiguration {
name = properties("pluginName")
}
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.set(emptyList())
}
java {
withSourcesJar()
toolchain {
languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
}
val genDir = file("src/main/gen")
idea.module.generatedSourceDirs.add(genDir)
sourceSets.main {
java.srcDirs(genDir)
}
val genAyaPsiParser = tasks.register<GenerateParserTask>("genAyaParser") {
group = "build setup"
sourceFile.set(file("src/main/grammar/AyaPsiParser.bnf"))
targetRootOutputDir.set(file("src/main/gen"))
pathToParser.set("org/aya/parser/AyaPsiParser.java")
pathToPsiRoot.set("org/aya/intellij/psi")
purgeOldFiles.set(true)
doLast {
// Already exists in "org.aya-prover:parser"
file("src/main/gen/org/aya/parser/AyaPsiParser.java").delete()
// We only need the Factory class
val src = file("src/main/gen/org/aya/parser/AyaPsiElementTypes.java")
val dst = file("src/main/gen/org/aya/parser/AyaPsiElementTypesFactory.java")
dst.writer().use { out ->
src.readLines().forEach { line ->
if (line == "public interface AyaPsiElementTypes {")
out.write(
"""
import static org.aya.parser.AyaPsiElementTypes.*;
public interface AyaPsiElementTypesFactory {
""".trimIndent(),
)
else if (!line.contains("IElementType (.+) = new AyaPsi(Element|Token)Type\\(\\\"(.+)\\\"\\);".toRegex()))
out.write("$line\n")
}
}
src.delete()
}
}
tasks {
compileJava.configure {
dependsOn(genAyaPsiParser)
}
named("sourcesJar").configure {
dependsOn(genAyaPsiParser)
}
withType<JavaCompile>().configureEach {
modularity.inferModulePath.set(true)
options.apply {
encoding = "UTF-8"
isDeprecation = true
release.set(javaVersion)
compilerArgs.addAll(listOf("-Xlint:unchecked", "--enable-preview"))
}
doLast {
val tree = fileTree(destinationDirectory)
tree.include("**/*.class")
tree.exclude("module-info.class")
val root = project.layout.buildDirectory.asFile.get().toPath().resolve("classes/java/main")
tree.forEach { BuildUtil.stripPreview(root, it.toPath()) }
}
dependsOn(genAyaPsiParser)
}
withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
dependsOn(genAyaPsiParser)
}
withType<Test>().configureEach {
jvmArgs = listOf(
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens=java.base/java.io=ALL-UNNAMED",
"--add-opens=java.desktop/sun.awt=ALL-UNNAMED",
"--add-opens=java.desktop/java.awt=ALL-UNNAMED",
"--add-opens=java.desktop/javax.swing=ALL-UNNAMED",
"--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED",
)
enableAssertions = true
reports.junitXml.mergeReruns.set(true)
}
patchPluginXml {
version = project.version.toString()
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set(properties("pluginUntilBuild"))
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
projectDir.resolve("README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"
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").run { markdownToHTML(this) },
)
// Get the latest available change notes from the changelog file
val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes.set(
with(changelog) {
renderItem(
(getOrNull(project.version.toString()) ?: 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"))
}
}
dependencies {
intellijPlatform {
intellijIdeaCommunity("2024.3")
bundledPlugin("com.intellij.java")
instrumentationTools()
testFramework(TestFrameworkType.Platform)
}
implementation("org.aya-prover", "producer", ayaVersion) {
exclude("org.aya-prover.upstream", "ij-parsing-core")
exclude("org.aya-prover.upstream", "ij-util-text")
exclude("org.aya-prover.upstream", "lang-syntax")
}
implementation("org.aya-prover", "ide-lsp", ayaVersion) {
exclude("org.aya-prover.upstream", "ij-parsing-core")
exclude("org.aya-prover.upstream", "ij-util-text")
exclude("org.aya-prover.upstream", "lang-syntax")
}
testImplementation(kotlin("test-junit"))
testImplementation(group = "org.opentest4j", name = "opentest4j", version = "1.2.0")
}