Search code examples
mavengradleintellij-idea

The download sources feature does not work in certain intellij versions


In IntelliJ IDEA 2024.1.2 (Ultimate Edition), when I clicked on Download Sources next to the text "Decompiled .class file, bytecode version: 52.0 (Java 8)" at the top to view the @Async annotation, it didn't work properly. (I was trying to see the comments in the @Async annotation.)

However, in IntelliJ IDEA 2022.1.4 (Ultimate Edition), the same feature works correctly for the same project.

The project is using Gradle version 6.5.1, and the repository is configured with the following:

repositories {
    mavenLocal()
    mavenCentral()
}

In the functioning version of IntelliJ(older version), the Gradle log shows:

> Task: db:DownloadSources
Attempt to download sources from MavenLocal
Attempt to download sources from MavenRepo
Sources were downloaded to /Users/username/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/5.2.8.RELEASE/~~~/spring-context-5.2.8.RELEASE- sources.jar

However, in the non-functioning versions of IntelliJ(new version), the logs show:

Could not find spring-context-5.2.8.RELEASE-sources.jar (org.springframework:spring-context:5.2.8.RELEASE).
     Searched in the following locations:
         file:/Users/username/.m2/repository/org/springframework/spring-context/5.2.8.RELEASE/spring-context-5.2.8.RELEASE-sources.jar

It seems that the functioning version creates a cache file in Gradle and displays comments properly, whereas the non-functioning version tries to import comments from the .m2 side even though it's using Gradle. In other words, it appears to be attempting to import from mavenLocal() instead of creating a temporary cache file.

Does anyone know how to achieve the desired behavior in the new version specified in this question?


Solution

  • This appears to be a known issue described in IDEA-349334.

    Please make sure to upvote it, to raise its' priority for the developers!