Skip to content

Commit 70da7a0

Browse files
authored
[infra] add parameterized runTarget to allow running against custom IDE targets (flutter#8910)
Adds support for running the plugin against custom target IDEs using the new [`intellijPlatformTesting`](https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-testing-extension.html) Gradle extension, introducing a new parameterized `runTarget`. ## Why not update `runIde` directly? In the new IntelliJ Platform Gradle Plugin (v2.x), the default `runIde` task is strictly bound to the main project dependency used for compilation (which is Android Studio in our project). To run against a different IDE *without* changing the compilation target (which would break compilation due to our project's hard dependencies on Android Studio APIs), the plugin requires using the `intellijPlatformTesting` extension to register a custom task. We can't easily re-target the default `runIde` task without also changing what we compile against. (And if we don't change what we compile against we're in the reflection business so we can compile in the absence of AS deps OR code splitting which is a headache; see relevant conversation in flutter#8865.) ## Details - Registers a custom `runIde` task named `runTarget` in `build.gradle.kts`. - Added support for `-Pide` (values: `AndroidStudio`, `IntelliJ`, `Ultimate`) and `-PideV` (version string or build number) properties. - Adds a self-documenting help output to `runTarget` that lists available options and examples when run without parameters, and then exits without launching the IDE. - Updates the existing `printProductsReleases` task to include instructions on how to map its output to the new `-Pide` and `-PideV` parameters. --- ## Sample Outputs ### 1. Running `runTarget` without parameters Running the task without parameters prints a help report and stops execution. ```bash ./gradlew runTarget ============================================================ runTarget - Available Options ============================================================ Valid values for -Pide: - AndroidStudio (default) - IntelliJ (IntelliJ IDEA Community) - Ultimate (IntelliJ IDEA Ultimate) Valid values for -PideV: - Any valid version string for the selected IDE. - Examples for IntelliJ/Ultimate: 2024.1, 2024.2, 2024.3, 2025.1 - Run './gradlew printProductsReleases' to see the full list. Examples: ./gradlew runTarget -Pide=IntelliJ -PideV=2025.1 ./gradlew runTarget -Pide=Ultimate -PideV=2025.1 ============================================================ Stopping execution. Please run with parameters to launch a specific IDE. ``` ### 2. Running printProductsReleases The task now prints mapping instructions after listing the available releases. ``` ./gradlew printProductsReleases IU-261.23567.71 IU-253.31033.53 IC-252.27397.28 Mapping printProductsReleases output to ideV: - The prefix (e.g., IU-, IC-) maps to -Pide (Ultimate, IntelliJ). - The number part (e.g., 261.23567.71) maps to -PideV. - Example: IU-261.23567.71 -> -Pide=Ultimate -PideV=261.23567.71 ``` Fixes: flutter#8909 --- Review the contribution guidelines below: - [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR. - [x] I've included the required information in the description above. - [x] My up-to-date information is in the `AUTHORS` file. - [x] I've updated `CHANGELOG.md` if appropriate. <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide](../CONTRIBUTING.md) and the [Flutter organization contributor guide]([https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Dart contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Java and Kotlin contributions should strive to follow Java and Kotlin best practices ([discussion](flutter#8098)). </details>
1 parent c471478 commit 70da7a0

2 files changed

Lines changed: 72 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,23 @@ name and contact info to the [AUTHORS](AUTHORS) file.
232232
- Expand `Edit configuration templates...` and verify that Flutter is present.
233233
- Click [+] and verify that Flutter is present.
234234
235+
### Running against custom target IDEs
236+
237+
To test or debug the plugin against a different IDE target (like IntelliJ IDEA Community or Ultimate) without changing the project's compilation target, you can use the custom `runTarget` Gradle task.
238+
239+
Run it from the command line specifying the target IDE and version:
240+
```bash
241+
./gradlew runTarget -Pide=IntelliJ -PideV=2025.1
242+
```
243+
244+
* **`-Pide`**: Valid values are `AndroidStudio` (default), `IntelliJ` (Community), and `Ultimate`.
245+
* **`-PideV`**: Any valid version string or build number for the selected IDE.
246+
247+
To see a full list of available options and usage examples, run the task without any parameters:
248+
```bash
249+
./gradlew runTarget
250+
```
251+
235252
## Provision Tool
236253
237254
This is not currently required. However, for debugging unit tests, it may be handy; please ignore for now.

build.gradle.kts

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,18 @@ tasks {
389389
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#how-to-check-the-latest-available-eap-release
390390
tasks {
391391
printProductsReleases {
392-
channels = listOf(ProductRelease.Channel.EAP)
393-
types = listOf(IntelliJPlatformType.IntellijIdeaCommunity)
392+
channels = listOf(ProductRelease.Channel.RELEASE, ProductRelease.Channel.EAP)
393+
types = listOf(IntelliJPlatformType.IntellijIdeaCommunity, IntelliJPlatformType.IntellijIdeaUltimate)
394394
untilBuild = provider { null }
395395

396396
doLast {
397397
productsReleases.get().max()
398+
println()
399+
println("Mapping printProductsReleases output to ideV:")
400+
println(" - The prefix (e.g., IU-, IC-) maps to -Pide (Ultimate, IntelliJ).")
401+
println(" - The number part (e.g., 261.23567.71) maps to -PideV.")
402+
println(" - Example: IU-261.23567.71 -> -Pide=Ultimate -PideV=261.23567.71")
403+
println()
398404
}
399405
}
400406
prepareJarSearchableOptions {
@@ -415,6 +421,53 @@ tasks {
415421
}
416422
}
417423

424+
intellijPlatformTesting {
425+
runIde {
426+
register("runTarget") {
427+
val target = project.findProperty("ide") as? String
428+
val version = project.findProperty("ideV") as? String
429+
430+
val actualTarget = target ?: "AndroidStudio"
431+
type = when (actualTarget) {
432+
"IntelliJ" -> IntelliJPlatformType.IntellijIdeaCommunity
433+
"Ultimate" -> IntelliJPlatformType.IntellijIdeaUltimate
434+
else -> IntelliJPlatformType.AndroidStudio
435+
}
436+
this.version = version ?: ideaVersion
437+
}
438+
}
439+
}
440+
441+
tasks.named("runTarget") {
442+
val target = project.findProperty("ide") as? String
443+
val version = project.findProperty("ideV") as? String
444+
445+
doFirst {
446+
if (target == null && version == null) {
447+
println("============================================================")
448+
println("runTarget - Available Options")
449+
println("============================================================")
450+
println("Valid values for -Pide:")
451+
println(" - AndroidStudio (default)")
452+
println(" - IntelliJ (IntelliJ IDEA Community)")
453+
println(" - Ultimate (IntelliJ IDEA Ultimate)")
454+
println()
455+
println("Valid values for -PideV:")
456+
println(" - Any valid version string for the selected IDE.")
457+
println(" - Examples for IntelliJ/Ultimate: 2024.1, 2024.2, 2024.3, 2025.1")
458+
println(" - Run './gradlew printProductsReleases' to see the full list.")
459+
println()
460+
println("Examples:")
461+
println(" ./gradlew runTarget -Pide=IntelliJ -PideV=2025.1")
462+
println(" ./gradlew runTarget -Pide=Ultimate -PideV=2025.1")
463+
println("============================================================")
464+
println("Stopping execution. Please run with parameters to launch a specific IDE.")
465+
466+
throw org.gradle.api.tasks.StopExecutionException()
467+
}
468+
}
469+
}
470+
418471
// A task to print the classpath used for compiling an IntelliJ plugin
419472
// Run with `./gradlew printCompileClasspath --no-configuration-cache `
420473
tasks.register<Task>("printCompileClasspath") {

0 commit comments

Comments
 (0)