Skip to content

Commit 4b2d5bb

Browse files
authored
Update the Flutter build logic to IntelliJ Platform Gradle Plugin version 2.1.0 (#7774)
See https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html This change adds support for building against IntelliJ Community 2024.3 EAP This resolves #7670 The optional dependency to add the Flutter coverage runner has been removed for the time being The variables, names and ordering between the runner.dart, product-matrix.json, gradle.properties and the build.gradle.kts files has been simplified with documentation, albeit with some TODOs. The verifier with this version, 2.1.0 does not yet work with the JxBrowser, com.teamdev dependencies
1 parent 1e261d6 commit 4b2d5bb

25 files changed

+411
-973
lines changed

.github/workflows/presubmit.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
version: [2023.3, 2024.1, 2024.2]
24+
version: [2023.3, 2024.1, 2024.2, 2024.3]
2525
steps:
2626
- name: checkout
2727
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

build.gradle.kts

+137-89
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,14 @@
11
/*
2-
* Copyright 2019 The Chromium Authors. All rights reserved.
2+
* Copyright 2024 The Chromium Authors. All rights reserved.
33
* Use of this source code is governed by a BSD-style license that can be
44
* found in the LICENSE file.
55
*/
66

7-
buildscript {
8-
repositories {
9-
mavenCentral()
10-
maven {
11-
url=uri("https://www.jetbrains.com/intellij-repository/snapshots/")
12-
}
13-
maven {
14-
url=uri("https://oss.sonatype.org/content/repositories/snapshots/")
15-
}
16-
maven {
17-
url=uri("https://www.jetbrains.com/intellij-repository/releases")
18-
}
19-
gradlePluginPortal()
20-
}
21-
}
22-
23-
plugins {
24-
id("org.jetbrains.intellij") version "1.17.3"
25-
id("org.jetbrains.kotlin.jvm") version "2.0.0"
26-
}
27-
28-
repositories {
29-
mavenLocal()
30-
mavenCentral()
31-
maven {
32-
url=uri("https://www.jetbrains.com/intellij-repository/snapshots/")
33-
}
34-
maven {
35-
url=uri("https://oss.sonatype.org/content/repositories/snapshots/")
36-
}
37-
maven {
38-
url=uri("https://www.jetbrains.com/intellij-repository/releases")
39-
}
40-
}
7+
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
8+
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
9+
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
10+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
11+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
4112

4213
// Specify UTF-8 for all compilations so we avoid Windows-1252.
4314
allprojects {
@@ -49,81 +20,158 @@ allprojects {
4920
}
5021
}
5122

52-
val ide: String by project
53-
val flutterPluginVersion: String by project
54-
val javaVersion: String by project
55-
val androidVersion: String by project
56-
val dartVersion: String by project
57-
val baseVersion: String by project
58-
val name: String by project
59-
val buildSpec: String by project
60-
val smaliPlugin: String by project
61-
val langPlugin: String by project
62-
val ideVersion: String by project
23+
repositories {
24+
mavenCentral()
25+
intellijPlatform {
26+
defaultRepositories()
27+
}
28+
}
29+
30+
plugins {
31+
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html
32+
// https://github.com/JetBrains/intellij-platform-gradle-plugin/releases
33+
id("org.jetbrains.intellij.platform") version "2.1.0"
34+
id("org.jetbrains.kotlin.jvm") version "2.0.0"
35+
}
6336

37+
val flutterPluginVersion = providers.gradleProperty("flutterPluginVersion").get()
38+
val ideaProduct = providers.gradleProperty("ideaProduct").get()
39+
val ideaVersion = providers.gradleProperty("ideaVersion").get()
40+
val dartPluginVersion = providers.gradleProperty("dartPluginVersion").get()
41+
// The Android Plugin version is only used if the ideaProduct is not "android-studio"
42+
val androidPluginVersion = providers.gradleProperty("androidPluginVersion").get()
43+
val sinceBuildInput = providers.gradleProperty("sinceBuild").get()
44+
val untilBuildInput = providers.gradleProperty("untilBuild").get()
6445
group = "io.flutter"
65-
version = flutterPluginVersion
6646

47+
// For debugging purposes:
48+
println("flutterPluginVersion: $flutterPluginVersion")
49+
println("ideaProduct: $ideaProduct")
50+
println("ideaVersion: $ideaVersion")
51+
println("dartPluginVersion: $dartPluginVersion")
52+
println("androidPluginVersion: $androidPluginVersion")
53+
println("sinceBuild: $sinceBuildInput")
54+
println("untilBuild: $untilBuildInput")
55+
println("group: $group")
56+
57+
kotlin {
58+
compilerOptions {
59+
apiVersion.set(KotlinVersion.KOTLIN_1_9)
60+
jvmTarget = JvmTarget.JVM_17
61+
}
62+
}
63+
val javaCompatibilityVersion = JavaVersion.VERSION_17
6764
java {
68-
sourceCompatibility = JavaVersion.toVersion(javaVersion)
69-
targetCompatibility = JavaVersion.toVersion(javaVersion)
65+
sourceCompatibility = javaCompatibilityVersion
66+
targetCompatibility = javaCompatibilityVersion
7067
}
7168

72-
intellij {
73-
pluginName.set(name)
74-
// This adds nullability assertions, but also compiles forms.
75-
instrumentCode.set(true)
76-
updateSinceUntilBuild.set(false)
77-
version.set(ideVersion)
78-
downloadSources.set(false)
79-
val pluginList = mutableListOf(
80-
project(":flutter-idea"), "java", "properties",
81-
"junit", "Git4Idea", "Kotlin", "gradle",
82-
"Groovy", "Dart:$dartVersion")
69+
dependencies {
70+
intellijPlatform {
71+
if (ideaProduct == "android-studio") {
72+
create(IntelliJPlatformType.AndroidStudio, ideaVersion)
73+
} else {//if (ide == "ideaIC") {
74+
create(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion)
75+
}
76+
testFramework(TestFrameworkType.Platform)
77+
val bundledPluginList = mutableListOf(
78+
"com.intellij.java",
79+
"com.intellij.properties",
80+
"JUnit",
81+
"Git4Idea",
82+
"org.jetbrains.kotlin",
83+
"org.jetbrains.plugins.gradle",
84+
"org.intellij.intelliLang",
85+
)
86+
if (ideaProduct == "android-studio") {
87+
bundledPluginList.add("org.jetbrains.android")
88+
bundledPluginList.add("com.android.tools.idea.smali")
89+
}
90+
val pluginList = mutableListOf("Dart:$dartPluginVersion")
91+
if (ideaProduct == "IC") {
92+
pluginList.add("org.jetbrains.android:$androidPluginVersion")
93+
}
8394

84-
// If 2023.3+ and IDEA (not AS), then "org.jetbrains.android:$androidVersion", otherwise "org.jetbrains.android",
85-
// see https://github.com/flutter/flutter-intellij/issues/7145
86-
if(ide == "android-studio") {
87-
pluginList.add("org.jetbrains.android")
88-
} else if (ide == "ideaIC") {
89-
pluginList.add("org.jetbrains.android:$androidVersion")
90-
}
95+
// Finally, add the plugins into their respective lists:
96+
// https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html#project-setup
97+
bundledPlugins(bundledPluginList)
98+
plugins(pluginList)
9199

92-
if (ide == "android-studio") {
93-
pluginList.add(smaliPlugin)
94-
}
95-
pluginList.add(langPlugin)
96-
if (ide == "android-studio") {
97-
type.set("AI")
98-
pluginList += listOf(project(":flutter-studio"))
100+
// The warning that "instrumentationTools()" is deprecated might be valid, however, this error is produced by Gradle IJ plugin version
101+
// 2.1.0 if this isn't included:
102+
// Caused by: org.gradle.api.GradleException: No Java Compiler dependency found.
103+
// Please ensure the `instrumentationTools()` entry is present in the project dependencies section along with the `intellijDependencies()` entry in the repositories section.
104+
// See: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
105+
instrumentationTools()
106+
// pluginVerifier()
99107
}
100-
plugins.set(pluginList)
101108
}
109+
//intellijPlatform {
110+
// pluginConfiguration {
111+
// version = flutterPluginVersion
112+
// ideaVersion {
113+
// sinceBuild = sinceBuildInput
114+
// untilBuild = untilBuildInput
115+
// }
116+
// }
117+
// // TODO (jwren) get the verifier to work, and enable in the github presubmit,
118+
// // the com.teamdev dep is having the verifier fail
119+
// // Verifier documentation: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification-ides
120+
// pluginVerification {
121+
// // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#mutePluginVerifierProblems
122+
// freeArgs = listOf(
123+
// "-mute",
124+
// "TemplateWordInPluginId"
125+
// )
126+
// ides {
127+
// if (ideaProduct == "android-studio") {
128+
// ide(IntelliJPlatformType.AndroidStudio, ideaVersion)
129+
// } else {
130+
// ide(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion)
131+
// }
132+
// recommended()
133+
//// select {
134+
//// types = listOf(IntelliJPlatformType.AndroidStudio)
135+
//// channels = listOf(ProductRelease.Channel.RELEASE)
136+
//// sinceBuild = sinceBuildInput
137+
//// untilBuild = untilBuildInput
138+
//// }
139+
// }
140+
// }
141+
//}
102142

143+
// Documentation for printProductsReleases:
144+
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#how-to-check-the-latest-available-eap-release
103145
tasks {
104-
buildSearchableOptions {
105-
enabled = false
106-
}
107-
prepareSandbox {
108-
dependsOn(":flutter-idea:prepareSandbox")
109-
if (ide == "android-studio") {
110-
dependsOn(":flutter-studio:prepareSandbox")
146+
printProductsReleases {
147+
channels = listOf(ProductRelease.Channel.EAP)
148+
types = listOf(IntelliJPlatformType.IntellijIdeaCommunity)
149+
untilBuild = provider { null }
150+
151+
doLast {
152+
productsReleases.get().max()
111153
}
112154
}
113155
}
114156

115157
dependencies {
116-
implementation(project("flutter-idea", "instrumentedJar")) // Second arg is required to use forms
117-
if (ide == "android-studio") {
158+
implementation(project("flutter-idea"))
159+
if (ideaProduct == "android-studio") {
118160
implementation(project("flutter-studio"))
119161
}
120162
}
121163

122164
tasks {
123-
instrumentCode {
124-
compilerVersion.set(baseVersion)
165+
prepareJarSearchableOptions {
166+
enabled = false
167+
}
168+
buildSearchableOptions {
169+
enabled = false
125170
}
126-
instrumentTestCode {
127-
compilerVersion.set(baseVersion)
171+
prepareSandbox {
172+
dependsOn(":flutter-idea:prepareSandbox")
173+
if (ideaProduct == "android-studio") {
174+
dependsOn(":flutter-studio:prepareSandbox")
175+
}
128176
}
129-
}
177+
}

0 commit comments

Comments
 (0)