Skip to content

[JEWEL-1309] Bump detekt from v1 to v2.0.0-alpha.3#3495

Open
DanielSouzaBertoldi wants to merge 1 commit into
JetBrains:masterfrom
DanielSouzaBertoldi:dsb/JEWEL-1225
Open

[JEWEL-1309] Bump detekt from v1 to v2.0.0-alpha.3#3495
DanielSouzaBertoldi wants to merge 1 commit into
JetBrains:masterfrom
DanielSouzaBertoldi:dsb/JEWEL-1225

Conversation

@DanielSouzaBertoldi
Copy link
Copy Markdown
Collaborator

@DanielSouzaBertoldi DanielSouzaBertoldi commented Apr 29, 2026

Context

In order to bump CMP to 1.11.0-beta03, we have to first bump Detekt to 2.0.0-alpha.3. This PR does exactly that, fixes all migration issues and updates gradle/IML/Bazel files accordingly.

The Surprise

With this update, we cannot run tests from detekt-plugin module through JPS anymore. The reason for that is because Detekt 2.0 updated its list of transitive dependencies which result in a clash of missing APIs from either IJP or kotlin-compiler directly 😬 Here's a more detailed explanation:

Detekt v1 used to depend on kotlin-compiler-embeddable (check POM here)

v2 ditched the embeddable version for the "slim" kotlin-compiler (check POM here)

This seemingly innocent change screws up our test suite for custom detekt rules, and we start getting this exception:

Error occurred during initialization of VM
java.lang.Error: com.intellij.util.lang.UrlClassLoader.(java.lang.ClassLoader)
at java.lang.ClassLoader.initSystemClassLoader(java.base@25.0.2/ClassLoader.java:1901)
at java.lang.System.initPhase3(java.base@25.0.2/System.java:1988)
Caused by: java.lang.NoSuchMethodException: com.intellij.util.lang.UrlClassLoader.(java.lang.ClassLoader)
at java.lang.Class.getConstructor0(java.base@25.0.2/Class.java:3187)
at java.lang.Class.getDeclaredConstructor(java.base@25.0.2/Class.java:2491)
at java.lang.ClassLoader.initSystemClassLoader(java.base@25.0.2/ClassLoader.java:1888)
at java.lang.System.initPhase3(java.base@25.0.2/System.java:1988)

From what I've gathered, that's because kotlin-compiler bundles its own UrlClassLoader without a ClassLoader constructor. When this class ends up in the classpath, anything trying to instantiate UrlClassLoader(parent) blows up. Apparently JPS needs this specific UrlClassLoader to start the test JVM.

The only UrlClassLoader with the right constructor comes from build 261's platform-loader.jar, but in this build ZipFilePool$EntryResolver.loadZipEntry(String) API got removed which detekt calls in its standalone JAR (detekt-kotlin-analysis-api-standalone-all.jar which bundles their own analysis API and some IntelliJ platform internals).

Which means we hit a huge wall here :pain-harold:

Using kotlin-compiler means we crash because the expected UrlClassLoader constructor can't be found
Using IntelliJ's ZipFilePool/UrlClassLoader from platform-loader.jar we break Detekt


The "good" news is that we can safely run tests via Gradle, and any other test outside the detekt-plugin module can be run normally via JPS

Comment thread lib/BUILD.bazel Outdated
Comment thread platform/jewel/buildSrc/src/main/kotlin/jewel-linting.gradle.kts
Comment thread platform/jewel/detekt.yml
Comment thread platform/jewel/detekt.yml
Comment thread platform/jewel/detekt.yml
Comment thread platform/jewel/detekt.yml
@DanielSouzaBertoldi DanielSouzaBertoldi changed the title [Jewel] Bump detekt from v1 to v2.0.0-alpha.3 [JEWEL-1225] Bump detekt from v1 to v2.0.0-alpha.3 Apr 29, 2026
@DanielSouzaBertoldi
Copy link
Copy Markdown
Collaborator Author

btw if you checked any of the links before clicking them, let it be known that I'm disappointed in you 😈

@DanielSouzaBertoldi DanielSouzaBertoldi changed the title [JEWEL-1225] Bump detekt from v1 to v2.0.0-alpha.3 [JEWEL-1309] Bump detekt from v1 to v2.0.0-alpha.3 Apr 30, 2026
@nebojsa-vuksic
Copy link
Copy Markdown
Collaborator

Great work @DanielSouzaBertoldi! 👏 I'll try fixing the JPS part internally.

Copy link
Copy Markdown
Collaborator

@rock3r rock3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, found a few issues to look at before we ship, but they should be quick fixes I hope

Comment thread platform/jewel/gradle/libs.versions.toml
@@ -38,8 +38,8 @@ jvm_library(
"@lib//:kotlin-stdlib",
"//libraries/kotlinx/coroutines/core",
"@lib//:jetbrains-annotations",
"@lib//:platform-jewel-detekt_plugin-jetbrains-kotlin-compiler-embeddable",
"@lib//:platform-jewel-detekt_plugin-io-gitlab-arturbosch-detekt-api",
"@lib//:platform-jewel-detekt_plugin-jetbrains-kotlin-compiler",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know Bazel that well, but this seems sus: the actual dependency was migrated to kotlin-compiler here, but the detekt-plugin-binary-excludes target above still points at the old kotlin-compiler-embeddable label. lib/BUILD.bazel only seems to define platform-jewel-detekt_plugin-jetbrains-kotlin-compiler now.

Should that exclusion be updated to the new label too?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm maybe???? I just ran the script and kinda went with it. Since bazel builds were broken by then I couldn't reliably test if this works. I'll give a try once again and let you know

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nebojsa-vuksic we need you :D

@DanielSouzaBertoldi DanielSouzaBertoldi force-pushed the dsb/JEWEL-1225 branch 5 times, most recently from 2b05f08 to fa11b28 Compare May 18, 2026 15:46
Group ID changed from io.gitlab.arturbosch.detekt to dev.detekt.
Updated all library entries, SHA256 checksums, and transitive deps
in both detektPlugin and detektPlugin.tests IML files.
Copy link
Copy Markdown
Collaborator

@rock3r rock3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but leaving @nebojsa-vuksic to answer the question and/or fix things :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants