-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle.kts
312 lines (261 loc) · 9.78 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
import com.adarshr.gradle.testlogger.theme.ThemeType
import de.undercouch.gradle.tasks.download.Download
import groovy.json.JsonSlurper
import org.commonmark.parser.Parser
import org.commonmark.renderer.html.HtmlRenderer
import org.gradle.api.JavaVersion.VERSION_11
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.intellij.tasks.PrepareSandboxTask
import org.jetbrains.intellij.tasks.RunPluginVerifierTask
buildscript {
dependencies {
classpath("org.commonmark:commonmark:0.17.2")
}
repositories {
mavenCentral()
maven { setUrl("https://www.jetbrains.com/intellij-repository/releases") }
}
}
plugins {
idea
id("org.jetbrains.intellij") version "1.13.2"
id("org.jetbrains.changelog") version "1.3.1"
id("com.adarshr.test-logger") version "3.2.0"
id("de.undercouch.download") version "5.4.0"
}
val pluginVersion = prop("pluginVersion")
val lombokVersion = prop("lombokVersion")
group = "appland.appmap"
version = pluginVersion
val isCI = System.getenv("CI") == "true"
val agentOutputPath = rootProject.buildDir.resolve("appmap-agent.jar")
val githubToken = System.getenv("GITHUB_TOKEN").takeUnless { it.isNullOrEmpty() }
allprojects {
repositories {
mavenCentral()
maven { setUrl("https://www.jetbrains.com/intellij-repository/releases") }
}
apply {
plugin("idea")
plugin("org.jetbrains.intellij")
plugin("com.adarshr.test-logger")
}
val testOutput = configurations.create("testOutput")
dependencies {
// for compatibility with IntelliJ Ultimate, IU-2021.3.3 doesn't include this for unknown reasons
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
// Jackson JSON is missing from 2023.1+
implementation("com.fasterxml.jackson.core:jackson-core:2.14.2")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.14.2")
// http://wiremock.org, Apache 2 license
testImplementation("com.github.tomakehurst:wiremock-jre8:2.33.1")
// Project Lombok, only for compilation
compileOnly("org.projectlombok:lombok:$lombokVersion")
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
// share test classes of plugin-core with other Gradle modules
testOutput(sourceSets.getByName("test").output)
if (project.name != "plugin-core") {
testImplementation(project(":plugin-core", "testOutput"))
}
}
intellij {
version.set(prop("ideVersion"))
downloadSources.set(!isCI)
updateSinceUntilBuild.set(true)
instrumentCode.set(true)
}
configure<JavaPluginExtension> {
sourceCompatibility = VERSION_11
targetCompatibility = VERSION_11
}
tasks {
buildSearchableOptions.get().enabled = false
buildPlugin {
dependsOn(":copyPluginAssets")
from("${rootProject.buildDir}/appmap-assets") {
into("")
include("**/*")
}
}
processTestResources {
dependsOn(":copyPluginAssets")
from("${rootProject.buildDir}/appmap-assets") {
into("")
include("**/*")
}
}
runIde {
onlyIf { this.project == rootProject }
systemProperty("appmap.sandbox", "true")
jvmArgs("-Xmx2048m")
}
verifyPlugin {
dependsOn(":copyPluginAssets")
onlyIf { this.project == rootProject }
}
withType<PrepareSandboxTask> {
dependsOn(":copyPluginAssets")
from("${rootProject.buildDir}/appmap-assets") {
into(intellij.pluginName.get())
include("**/*")
}
}
withType<Test> {
systemProperty("idea.test.execution.policy", "appland.AppLandTestExecutionPolicy")
systemProperty("appland.testDataPath", rootProject.rootDir.resolve("src/test/data").path)
if (isCI && githubToken != null) {
systemProperty("appland.github_token", githubToken)
}
// to allow tests to access the custom Java 11 JDK
systemProperties["NO_FS_ROOTS_ACCESS_CHECK"] = true
// always execute tests, don't skip by Gradle's up-to-date checks in development
outputs.upToDateWhen { false }
// attach AppMap agent, but only if Gradle is online
dependsOn(":downloadAppMapAgent")
jvmArgs("-javaagent:$agentOutputPath",
"-Dappmap.config.file=${rootProject.file("appmap.yml")}",
"-Dappmap.output.directory=${rootProject.file("tmp/appmap")}")
systemProperty("appmap.test.withAgent", "true")
// logging setup
testLogging {
setEvents(listOf(TestLogEvent.FAILED, TestLogEvent.STANDARD_OUT, TestLogEvent.STANDARD_ERROR))
}
testlogger {
theme = ThemeType.PLAIN
}
}
withType<RunPluginVerifierTask> {
onlyIf { this.project == rootProject }
ideVersions.set(prop("ideVersionVerifier").split(","))
}
withType<Zip> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
project(":") {
dependencies {
implementation(project(":plugin-core", "instrumentedJar"))
implementation(project(":plugin-gradle", "instrumentedJar"))
implementation(project(":plugin-java", "instrumentedJar"))
implementation(project(":plugin-maven", "instrumentedJar"))
}
changelog {
path.set("${project.projectDir}/CHANGELOG.md")
}
tasks {
task<Copy>("copyPluginAssets") {
inputs.dir("${project.rootDir}/appland")
inputs.dir("${project.rootDir}/appland-install-guide")
inputs.dir("${project.rootDir}/appland-findings")
inputs.dir("${project.rootDir}/appland-signin")
destinationDir = project.buildDir
from("${project.rootDir}/appland") {
into("appmap-assets/appmap")
include("index.html")
include("dist/**")
}
from("${project.rootDir}/appland-install-guide") {
into("appmap-assets/appland-install-guide")
include("index.html")
include("dist/**")
}
from("${project.rootDir}/appland-findings") {
into("appmap-assets/appland-findings")
include("index.html")
include("dist/**")
}
from("${project.rootDir}/appland-signin") {
into("appmap-assets/appland-signin")
include("index.html")
include("dist/**")
}
processResources {
dependsOn("copyPluginAssets")
}
instrumentCode {
dependsOn("copyPluginAssets")
}
jar {
dependsOn("copyPluginAssets")
}
instrumentedJar {
dependsOn("copyPluginAssets")
}
}
patchPluginXml {
dependsOn(":copyPluginAssets")
sinceBuild.set(prop("sinceBuild"))
untilBuild.set(prop("untilBuild"))
pluginDescription.set(file("${rootDir}/description.md").readText().renderMarkdown())
changeNotes.set(provider {
if (pluginVersion.endsWith("-SNAPSHOT")) {
changelog.getUnreleased().toHTML()
} else {
changelog.get(pluginVersion).toHTML()
}
})
}
@Suppress("UNCHECKED_CAST")
task<Download>("downloadAppMapAgent") {
src("https://api.github.com/repos/getappmap/appmap-java/releases/latest")
dest(project.buildDir.resolve("appmap-java.json"))
overwrite(true)
quiet(true)
if (isCI && githubToken != null) {
header("Authorization", "Bearer $githubToken")
}
doLast {
val json = JsonSlurper().parseText(dest.readText()) as Map<*, *>
val jarAsset = (json["assets"] as List<Map<*, *>>)
.filter { (it["name"] as? String)?.endsWith(".jar") == true }
.map { it["browser_download_url"]!! }
.firstOrNull()
download.run {
src(jarAsset)
dest(agentOutputPath)
overwrite(false)
if (isCI && githubToken != null) {
header("Authorization", "Bearer $githubToken")
}
}
}
}
}
}
project(":plugin-java") {
dependencies {
implementation(project(":plugin-core", "instrumentedJar"))
}
intellij {
plugins.set(listOf("java"))
}
}
project(":plugin-gradle") {
dependencies {
implementation(project(":plugin-core", "instrumentedJar"))
implementation(project(":plugin-java", "instrumentedJar"))
}
intellij {
plugins.set(listOf("java", "gradle"))
}
}
project(":plugin-maven") {
dependencies {
implementation(project(":plugin-core", "instrumentedJar"))
implementation(project(":plugin-java", "instrumentedJar"))
}
intellij {
plugins.set(listOf("java", "maven"))
}
}
// https://github.com/commonmark/commonmark-java
fun String.renderMarkdown(): String {
val parser = Parser.builder().build()
val document = parser.parse(this)
val renderer = HtmlRenderer.builder().build()
return renderer.render(document).trim()
}
fun prop(name: String): String {
return extra.properties[name] as? String ?: error("Property `$name` is not defined in gradle.properties")
}