forked from flutter/flutter-intellij
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
332 lines (300 loc) · 10.9 KB
/
build.gradle.kts
File metadata and controls
332 lines (300 loc) · 10.9 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
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
/*
* Copyright 2024 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
import okhttp3.internal.immutableListOf
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
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.models.ProductRelease
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import java.time.LocalDate
import java.time.format.DateTimeFormatter
// Specify UTF-8 for all compilations so we avoid Windows-1252.
allprojects {
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.withType<Test> {
systemProperty("file.encoding", "UTF-8")
}
}
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}
plugins {
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html
// https://plugins.gradle.org/plugin/org.jetbrains.intellij.platform
// https://plugins.gradle.org/plugin/org.jetbrains.kotlin.jvm
id("java") // Java support
id("org.jetbrains.intellij.platform") version "2.7.2" // IntelliJ Platform Gradle Plugin
id("org.jetbrains.kotlin.jvm") version "2.2.0" // Kotlin support
id("org.jetbrains.changelog") version "2.2.0" // Gradle Changelog Plugin
}
// By default (e.g. when we call `runIde` during development), the plugin version is SNAPSHOT
var flutterPluginVersion = "SNAPSHOT"
// Otherwise, we will decide on the proper semver-formatted version from the CHANGELOG.
// Note: The CHANGELOG follows the style from https://keepachangelog.com/en/1.0.0/ so that we can use the gradle changelog plugin.
if (project.hasProperty("release")) {
// If we are building for a release, the changelog should be updated with the latest version.
flutterPluginVersion = changelog.getLatest().version
} else if (project.hasProperty("dev")) {
// If we are building the dev version, the version label will increment the latest version from the changelog and append the date.
val latestVersion = changelog.getLatest().version
val majorVersion = latestVersion.substringBefore('.').toInt()
val nextMajorVersion = majorVersion + 1
val datestamp = DateTimeFormatter.ofPattern("yyyyMMdd").format(LocalDate.now())
flutterPluginVersion = "$nextMajorVersion.0.0-dev.$datestamp"
}
val ideaVersion = providers.gradleProperty("ideaVersion").get()
val dartPluginVersion = providers.gradleProperty("dartPluginVersion").get()
val sinceBuildInput = providers.gradleProperty("sinceBuild").get()
val untilBuildInput = providers.gradleProperty("untilBuild").get()
val javaVersion = providers.gradleProperty("javaVersion").get()
group = "io.flutter"
// For debugging purposes:
println("flutterPluginVersion: $flutterPluginVersion")
println("ideaVersion: $ideaVersion")
println("dartPluginVersion: $dartPluginVersion")
println("sinceBuild: $sinceBuildInput")
println("untilBuild: $untilBuildInput")
println("javaVersion: $javaVersion")
println("group: $group")
var jvmVersion: JvmTarget
jvmVersion = when (javaVersion) {
"17" -> {
JvmTarget.JVM_17
}
"21" -> {
JvmTarget.JVM_21
}
else -> {
throw IllegalArgumentException("javaVersion must be defined in the product matrix as either \"17\" or \"21\", but is not for $ideaVersion")
}
}
kotlin {
compilerOptions {
apiVersion.set(KotlinVersion.KOTLIN_2_1)
jvmTarget = jvmVersion
}
}
var javaCompatibilityVersion: JavaVersion
javaCompatibilityVersion = when (javaVersion) {
"17" -> {
JavaVersion.VERSION_17
}
"21" -> {
JavaVersion.VERSION_21 // all later versions of java can build against the earlier versions
}
else -> {
throw IllegalArgumentException("javaVersion must be defined in the product matrix as either \"17\" or \"21\", but is not for $ideaVersion")
}
}
java {
sourceCompatibility = javaCompatibilityVersion
targetCompatibility = javaCompatibilityVersion
}
dependencies {
intellijPlatform {
// Documentation on the default target platform methods:
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#default-target-platforms
// Android Studio versions can be found at: https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html
androidStudio(ideaVersion)
testFramework(TestFrameworkType.Platform)
// Plugin dependency documentation:
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#plugins
// https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html#project-setup
bundledPlugins(
immutableListOf(
"com.google.tools.ij.aiplugin",
"com.intellij.java",
"com.intellij.properties",
"JUnit",
"Git4Idea",
"org.jetbrains.kotlin",
"org.jetbrains.plugins.gradle",
"org.jetbrains.plugins.yaml",
"org.intellij.intelliLang",
"org.jetbrains.android",
"com.android.tools.idea.smali"
)
)
plugin("Dart:$dartPluginVersion")
if (sinceBuildInput == "243" || sinceBuildInput == "251") {
bundledModule("intellij.platform.coverage")
bundledModule("intellij.platform.coverage.agent")
}
pluginVerifier()
}
compileOnly("org.jetbrains:annotations:24.0.0")
testImplementation("org.jetbrains:annotations:24.0.0")
compileOnly("com.google.guava:guava:32.0.1-android")
compileOnly("com.google.code.gson:gson:2.10.1")
testImplementation("com.google.guava:guava:32.0.1-jre")
testImplementation("com.google.code.gson:gson:2.10.1")
testImplementation("junit:junit:4.13.2")
implementation(
fileTree(
mapOf(
"dir" to "${project.rootDir}/third_party/lib/jxbrowser",
"include" to listOf("*.jar")
)
)
)
}
intellijPlatform {
pluginConfiguration {
version = flutterPluginVersion
ideaVersion {
sinceBuild = sinceBuildInput
untilBuild = untilBuildInput
}
changeNotes = provider {
project.changelog.render(Changelog.OutputType.HTML)
}
}
// Verifier documentation
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification-ides
pluginVerification {
// https://github.com/JetBrains/intellij-plugin-verifier/?tab=readme-ov-file#specific-options
// https://github.com/JetBrains/intellij-plugin-verifier
cliPath = file("./third_party/lib/verifier-cli-1.394-all.jar")
failureLevel = listOf(
// TODO(team) Ideally all of the following FailureLevels should be enabled:
// https://github.com/flutter/flutter-intellij/issues/8361
VerifyPluginTask.FailureLevel.COMPATIBILITY_WARNINGS,
VerifyPluginTask.FailureLevel.COMPATIBILITY_PROBLEMS,
// VerifyPluginTask.FailureLevel.DEPRECATED_API_USAGES, // https://github.com/flutter/flutter-intellij/issues/7718
// VerifyPluginTask.FailureLevel.SCHEDULED_FOR_REMOVAL_API_USAGES,
// `BadgeIcon`:
// VerifyPluginTask.FailureLevel.EXPERIMENTAL_API_USAGES,
// VerifyPluginTask.FailureLevel.INTERNAL_API_USAGES,
// VerifyPluginTask.FailureLevel.OVERRIDE_ONLY_API_USAGES,
VerifyPluginTask.FailureLevel.NON_EXTENDABLE_API_USAGES,
VerifyPluginTask.FailureLevel.PLUGIN_STRUCTURE_WARNINGS,
VerifyPluginTask.FailureLevel.MISSING_DEPENDENCIES,
VerifyPluginTask.FailureLevel.INVALID_PLUGIN,
// VerifyPluginTask.FailureLevel.NOT_DYNAMIC,
)
verificationReportsFormats = VerifyPluginTask.VerificationReportsFormats.ALL
subsystemsToCheck = VerifyPluginTask.Subsystems.ALL
ides {
recommended()
}
}
}
sourceSets {
main {
java.srcDirs(
listOf(
"src",
"third_party/vmServiceDrivers"
)
)
// Add kotlin.srcDirs if we start using Kotlin in the main plugin.
resources.srcDirs(
listOf(
"src",
"resources"
)
)
}
test {
java.srcDirs(
listOf(
"src",
"testSrc/unit",
"third_party/vmServiceDrivers"
)
)
resources.srcDirs(
listOf(
"resources",
"testData",
"testSrc/unit"
)
)
}
}
// Documentation for printProductsReleases:
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#how-to-check-the-latest-available-eap-release
tasks {
printProductsReleases {
channels = listOf(ProductRelease.Channel.EAP)
types = listOf(IntelliJPlatformType.IntellijIdeaCommunity)
untilBuild = provider { null }
doLast {
productsReleases.get().max()
}
}
prepareJarSearchableOptions {
enabled = false
}
buildSearchableOptions {
enabled = false
}
test {
useJUnit()
testLogging {
showCauses = true
showStackTraces = true
showStandardStreams = true
exceptionFormat = TestExceptionFormat.FULL
events("skipped", "failed")
}
}
}
// A task to print the classpath used for compiling an IntelliJ plugin
// Run with `./gradlew printCompileClasspath --no-configuration-cache `
tasks.register<Task>("printCompileClasspath") {
doLast {
println("--- Begin Compile Classpath ---")
configurations.getByName("compileClasspath").forEach { file ->
println(file.absolutePath)
}
println("--- End Compile Classpath ---")
}
}
// This finds the JxBrowser license key from the environment and writes it to a file.
// This is only used by the dev build on kokoro for now.
val writeLicenseKey = tasks.register<Task>("writeLicenseKey") {
group = "build"
description = "Writes the license key from an environment variable to a file."
// Find the output file
val outputDir = rootProject.file("resources/jxbrowser")
val licenseFile = outputDir.resolve("jxbrowser.properties")
outputs.file(licenseFile)
doLast {
// Read the license key from the environment variable
val base = System.getenv("KOKORO_KEYSTORE_DIR")
val id = System.getenv("FLUTTER_KEYSTORE_ID")
val name = System.getenv("FLUTTER_KEYSTORE_JXBROWSER_KEY_NAME")
val readFile = File(base + "/" + id + "_" + name)
if (readFile.isFile) {
val licenseKey = readFile.readText(Charsets.UTF_8)
licenseFile.writeText("jxbrowser.license.key=$licenseKey")
}
}
}
tasks.named("buildPlugin") {
dependsOn(writeLicenseKey)
}
tasks.named("processResources") {
dependsOn(writeLicenseKey)
}
// TODO(helin24): Find a better way to skip checking this file for tests.
tasks.withType<ProcessResources>().configureEach {
if (name == "processTestResources") {
// This block will only execute for the 'processTestResources' task.
// The context here is unambiguously the task itself.
exclude("jxbrowser/jxbrowser.properties")
}
}