Repository navigation
build: turn off code instrumentation, which goes through Gradle's deprecated Ant integration - #2072
Conversation
…recated Ant integration The IntelliJ Platform Gradle Plugin instruments the classes through Task.getAnt(), which Gradle 9.9 deprecates and Gradle 10 removes (JetBrains/intellij-platform-gradle-plugin#2294). LSP4IJ has no GUI Designer forms, so the instrumentation only added null checks for @NotNull to its classes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2072 +/- ##
==========================================
+ Coverage 49.91% 50.16% +0.25%
==========================================
Files 813 813
Lines 33396 33497 +101
Branches 6872 5221 -1651
==========================================
+ Hits 16668 16803 +135
+ Misses 14138 14064 -74
- Partials 2590 2630 +40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
Action performed
|
@lagergren I would suggest opening an issue at https://youtrack.jetbrains.com/, as that is the main issue tracker, rather than using the GitHub mirror. (And the same applies to PRs on the GitHub mirror: they only respond to PRs if you have also created a corresponding issue in YouTrack.) |
…il it when it finds no test (#2125) ## What `testJavaScript` runs the JavaScript plugin tests again (`*JavaScriptPluginTest`, today `DAPExpressionCodeFragmentJavaScriptPluginTest`). It now fails the build when, on an IDE that bundles the JavaScript plugin, it finds no test class. ## Cause Since #2072 set `instrumentCode = false`, `testJavaScript` has found no test class: on CI's IU 2026.3 leg, it logs `Task :testJavaScript NO-SOURCE`, and the build passes. The last run of `main` where the test ran is that of fe9f583, just before #2072 (run 44925663365); from cc1776f, #2072 itself, every run logs NO-SOURCE. Gradle 9 gives the classes and the classpath of the test source set to the `test` task only. Of those, the IntelliJ Platform Gradle Plugin 2.20.0 gives a `testIde` task only the classes of `instrumentTestCode` (`TestIdeTask`: `testClassesDirs = instrumentedTestCode + testClassesDirs`), which `instrumentCode = false` leaves empty. A local build can hide this: a leftover `build/instrumented/instrumentTestCode` from a build with instrumentation on makes the task run those old classes. ## Change - `testJavaScript` takes `testClassesDirs` from the test source set. It also adds the test runtime classpath without that of main, whose classes and dependencies come from the plugin in the sandbox, as for `test`. That's what the plugin's own integration tests do for a `testIde` task with `instrumentCode = false`. The test resources, and with them the `HangingTestWatchdog` listener, are now on its classpath too. - Gradle skips a test task that finds no test class as NO-SOURCE, before `failOnNoDiscoveredTests` can apply. A second `onlyIf`, evaluated before that skip and only where the IDE bundles the JavaScript plugin, fails the build when `testJavaScript` finds no `*JavaScriptPluginTest` class. - `instrumentCode = false` stays (#2121 tracks JetBrains/intellij-platform-gradle-plugin#2294). ## Test - `./gradlew testJavaScript -PplatformType=IU -PplatformVersion=2026.3 --rerun-tasks --no-build-cache` runs 1 test, which passes, 4 times out of 4. The configuration cache is stored and then reused. - On the default IC 2024.2, the task is skipped, as the `onlyIf` for the JavaScript plugin is false, and the build passes. - With the new lines removed, `testJavaScript` on IU 2026.3 fails: "Could not evaluate spec for 'testJavaScript finds a **/*JavaScriptPluginTest.class'". On IC 2024.2 it's still skipped. - `./gradlew check -PplatformType=IU -PplatformVersion=2026.3 --rerun-tasks --no-build-cache` passes: `test` runs 1861 tests (7 skipped), and `testJavaScript` runs 1, with no failures. `DAPExpressionCodeFragmentJavaScriptPluginTest` still passes after a day of not running.
What
Sets
instrumentCode = falsein theintellijPlatform { }block ofbuild.gradle.kts.Why
The
instrumentCodetask of the IntelliJ Platform Gradle Plugin callsTask.getAnt()(InstrumentCodeTask.prepareAntClassLoader). With--warning-mode all, the build reports:Gradle 9.9 deprecates the whole Ant integration, and Gradle 10 removes it. Once LSP4IJ moves to Gradle 10, the build would fail at
instrumentCode. The plugin still callsgetAnt()in 2.20.0 and on itsmainbranch. The upstream issue is JetBrains/intellij-platform-gradle-plugin#2294.Trade-off
LSP4IJ has no GUI Designer
.formfiles, so instrumentation only added runtime null checks for@NotNullparameters and return values. Those checks go away. A null passed where@NotNullis declared no longer fails at once with anIllegalArgumentException, or anIllegalStateExceptionfor a return value. It now fails later, where the value is used, or not at all. The IDE's static analysis still reports those nulls. Instrumentation can be turned back on once the plugin no longer needs Ant for it.Verification
./gradlew build --warning-mode all, with the configuration cache on asgradle.propertiessets it, no longer reportsTask.getAnt(). Two warnings remain: Kover'sConfiguration.setVisible(build: upgrade Kover once a release fixes the deprecation of Configuration.setVisible #2068) and the Kotlin language version warning.