Gradle project attaches multiple versions of the sources jar when importing a dependency
This is a "non-standard" situation, so I'm writing here first instead of posting a support request.
I'm a contributor to the Minecraft Forge project, which does its development environment magic through gradle plugins. One of the things it does is create an artificial dependency provided through a virtual repository. The issue is, as described in the title:

Every time I change the dependency version, and this triggers the gradle plugin to produce a new artificial dependency, IntelliJ attaches one more source jar to the list. I have been unable to figure out what could cause this and I wonder if anyone here would have any idea about what IntelliJ uses to discover source jars, in case that would provide some hint as to why it's discovering increasingly many of them.
Please sign in to leave a comment.
Hello David,
Is it reproducible with any sample project example?
I can easily reproduce it simply by setting up more than one version of the MDK (mod developer kit) from http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.13.2.html (you can bypass the adfocus links by hovering over the "(i)" icon in the "show all versions" table)
For the purposes of reproducing this issue, just importing the build.gradle file as a project does the trick, other setup steps shouldn't be necessary.
Eg. I cleaned the caches and then afterward set up version 25.0.48, and it was fine, then edited the build.gradle script to use version 52 instead, and this added the sources of both 48 and 52 to the library.
I have now changed he buildscript to version 54, and yep, sources for 48 and 52 are still there.
Do note that setting up an MDK version takes a few minutes, due to the need to decompile and patch the Minecraft binaries.
I wish I could provide a smaller project setup, but I wouldn't know how to extract the relevant parts out of ForgeGradle.
David,
Thanks! Reproduced. Please follow the issue on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-207941