Skip to content

Commit

Permalink
Update the Flutter build logic to IntelliJ Platform Gradle Plugin ver…
Browse files Browse the repository at this point in the history
…sion 2.1.0

This change adds support for building against IntelliJ Community 2024.3 EAP

This resolves flutter#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
  • Loading branch information
jwren committed Nov 10, 2024
1 parent 1e261d6 commit 0732407
Show file tree
Hide file tree
Showing 25 changed files with 411 additions and 973 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [2023.3, 2024.1, 2024.2]
version: [2023.3, 2024.1, 2024.2, 2024.3]
steps:
- name: checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
Expand Down
226 changes: 137 additions & 89 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,43 +1,14 @@
/*
* Copyright 2019 The Chromium Authors. All rights reserved.
* 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.
*/

buildscript {
repositories {
mavenCentral()
maven {
url=uri("https://www.jetbrains.com/intellij-repository/snapshots/")
}
maven {
url=uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
maven {
url=uri("https://www.jetbrains.com/intellij-repository/releases")
}
gradlePluginPortal()
}
}

plugins {
id("org.jetbrains.intellij") version "1.17.3"
id("org.jetbrains.kotlin.jvm") version "2.0.0"
}

repositories {
mavenLocal()
mavenCentral()
maven {
url=uri("https://www.jetbrains.com/intellij-repository/snapshots/")
}
maven {
url=uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
maven {
url=uri("https://www.jetbrains.com/intellij-repository/releases")
}
}
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.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

// Specify UTF-8 for all compilations so we avoid Windows-1252.
allprojects {
Expand All @@ -49,81 +20,158 @@ allprojects {
}
}

val ide: String by project
val flutterPluginVersion: String by project
val javaVersion: String by project
val androidVersion: String by project
val dartVersion: String by project
val baseVersion: String by project
val name: String by project
val buildSpec: String by project
val smaliPlugin: String by project
val langPlugin: String by project
val ideVersion: String by project
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}

plugins {
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html
// https://github.com/JetBrains/intellij-platform-gradle-plugin/releases
id("org.jetbrains.intellij.platform") version "2.1.0"
id("org.jetbrains.kotlin.jvm") version "2.0.0"
}

val flutterPluginVersion = providers.gradleProperty("flutterPluginVersion").get()
val ideaProduct = providers.gradleProperty("ideaProduct").get()
val ideaVersion = providers.gradleProperty("ideaVersion").get()
val dartPluginVersion = providers.gradleProperty("dartPluginVersion").get()
// The Android Plugin version is only used if the ideaProduct is not "android-studio"
val androidPluginVersion = providers.gradleProperty("androidPluginVersion").get()
val sinceBuildInput = providers.gradleProperty("sinceBuild").get()
val untilBuildInput = providers.gradleProperty("untilBuild").get()
group = "io.flutter"
version = flutterPluginVersion

// For debugging purposes:
println("flutterPluginVersion: $flutterPluginVersion")
println("ideaProduct: $ideaProduct")
println("ideaVersion: $ideaVersion")
println("dartPluginVersion: $dartPluginVersion")
println("androidPluginVersion: $androidPluginVersion")
println("sinceBuild: $sinceBuildInput")
println("untilBuild: $untilBuildInput")
println("group: $group")

kotlin {
compilerOptions {
apiVersion.set(KotlinVersion.KOTLIN_1_9)
jvmTarget = JvmTarget.JVM_17
}
}
val javaCompatibilityVersion = JavaVersion.VERSION_17
java {
sourceCompatibility = JavaVersion.toVersion(javaVersion)
targetCompatibility = JavaVersion.toVersion(javaVersion)
sourceCompatibility = javaCompatibilityVersion
targetCompatibility = javaCompatibilityVersion
}

intellij {
pluginName.set(name)
// This adds nullability assertions, but also compiles forms.
instrumentCode.set(true)
updateSinceUntilBuild.set(false)
version.set(ideVersion)
downloadSources.set(false)
val pluginList = mutableListOf(
project(":flutter-idea"), "java", "properties",
"junit", "Git4Idea", "Kotlin", "gradle",
"Groovy", "Dart:$dartVersion")
dependencies {
intellijPlatform {
if (ideaProduct == "android-studio") {
create(IntelliJPlatformType.AndroidStudio, ideaVersion)
} else {//if (ide == "ideaIC") {
create(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion)
}
testFramework(TestFrameworkType.Platform)
val bundledPluginList = mutableListOf(
"com.intellij.java",
"com.intellij.properties",
"JUnit",
"Git4Idea",
"org.jetbrains.kotlin",
"org.jetbrains.plugins.gradle",
"org.intellij.intelliLang",
)
if (ideaProduct == "android-studio") {
bundledPluginList.add("org.jetbrains.android")
bundledPluginList.add("com.android.tools.idea.smali")
}
val pluginList = mutableListOf("Dart:$dartPluginVersion")
if (ideaProduct == "IC") {
pluginList.add("org.jetbrains.android:$androidPluginVersion")
}

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

if (ide == "android-studio") {
pluginList.add(smaliPlugin)
}
pluginList.add(langPlugin)
if (ide == "android-studio") {
type.set("AI")
pluginList += listOf(project(":flutter-studio"))
// The warning that "instrumentationTools()" is deprecated might be valid, however, this error is produced by Gradle IJ plugin version
// 2.1.0 if this isn't included:
// Caused by: org.gradle.api.GradleException: No Java Compiler dependency found.
// Please ensure the `instrumentationTools()` entry is present in the project dependencies section along with the `intellijDependencies()` entry in the repositories section.
// See: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
instrumentationTools()
// pluginVerifier()
}
plugins.set(pluginList)
}
//intellijPlatform {
// pluginConfiguration {
// version = flutterPluginVersion
// ideaVersion {
// sinceBuild = sinceBuildInput
// untilBuild = untilBuildInput
// }
// }
// // TODO (jwren) get the verifier to work, and enable in the github presubmit,
// // the com.teamdev dep is having the verifier fail
// // Verifier documentation: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification-ides
// pluginVerification {
// // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#mutePluginVerifierProblems
// freeArgs = listOf(
// "-mute",
// "TemplateWordInPluginId"
// )
// ides {
// if (ideaProduct == "android-studio") {
// ide(IntelliJPlatformType.AndroidStudio, ideaVersion)
// } else {
// ide(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion)
// }
// recommended()
//// select {
//// types = listOf(IntelliJPlatformType.AndroidStudio)
//// channels = listOf(ProductRelease.Channel.RELEASE)
//// sinceBuild = sinceBuildInput
//// untilBuild = untilBuildInput
//// }
// }
// }
//}

// 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 {
buildSearchableOptions {
enabled = false
}
prepareSandbox {
dependsOn(":flutter-idea:prepareSandbox")
if (ide == "android-studio") {
dependsOn(":flutter-studio:prepareSandbox")
printProductsReleases {
channels = listOf(ProductRelease.Channel.EAP)
types = listOf(IntelliJPlatformType.IntellijIdeaCommunity)
untilBuild = provider { null }

doLast {
productsReleases.get().max()
}
}
}

dependencies {
implementation(project("flutter-idea", "instrumentedJar")) // Second arg is required to use forms
if (ide == "android-studio") {
implementation(project("flutter-idea"))
if (ideaProduct == "android-studio") {
implementation(project("flutter-studio"))
}
}

tasks {
instrumentCode {
compilerVersion.set(baseVersion)
prepareJarSearchableOptions {
enabled = false
}
buildSearchableOptions {
enabled = false
}
instrumentTestCode {
compilerVersion.set(baseVersion)
prepareSandbox {
dependsOn(":flutter-idea:prepareSandbox")
if (ideaProduct == "android-studio") {
dependsOn(":flutter-studio:prepareSandbox")
}
}
}
}
Loading

0 comments on commit 0732407

Please sign in to comment.