Repository navigation
Android: Show class sources in IDE - #6856
Conversation
|
this looks reasonable to me but I'm not familiar with that area, we'll need some help reviewing to see if it's in the right direction @lihaoyi @lefou Also if you could attach a small video recording with the sources working @souvlakias , would be great |
|
If it's in the right direction, it might be a good time to organize all of the tasks that extract aars into using a helper task that extracts all of them instead of every task extracting to its own Task.dest. (I mean that I just messed with If it would be out of scope, this could be done in a different PR |
I think this is an important fix, we can follow up with optimisations on follow up prs |
| def resolvedMvnJarSources: T[Seq[PathRef]] = Task { | ||
| resolvedMvnDeps0(sources = true)() | ||
| } |
There was a problem hiding this comment.
Why is this required to show source JARs in the IDE?
There was a problem hiding this comment.
ressolvedMnvDeps0 is private in JavaModule, so this serves as a way for the AndroidModule to easily get the sources.jars
There was a problem hiding this comment.
Maybe we can just change resolvedMvnDeps0 to private[mill] and avoid another public task?
If not, I find the name unlucky, since Sources suffix is typically not associated archives but plain files. Instead, we could name it resolvedMvnSourceJars (If it is guaranteed to always be jar files) or resolvedMvnSourceDeps.
There was a problem hiding this comment.
I saw you renamed it. So why not the first option?
There was a problem hiding this comment.
If you mean the private[mill] vs having a public task, both felt acceptable so I just went with the clearer api.
About the name, im not sure about the "only jars" guarantee so the latter suggestion (resolvedMvnSourceDeps) seemed ok too.
If you prefer to avoid the public task, yes I can change to private[mill]
There was a problem hiding this comment.
from my point of view, let's not increase the surface of the API if not necessary @souvlakias (e.g. especially since JavaModule is not experimental), it is convenient to run it directly and check the output, but since this looks straightforward functionality to me, private[mill] is preferable for me
There was a problem hiding this comment.
changed to private[mill]
Addresses #6634
This is a POC on linking the classes jar with their respective sources.jar using bsp
The problem
Since android deps are aars, we extract them into a Task.dest and pass the found
.jars into the classpath.Bsp sees the
sources.jars that exist in~/.cache/coursierand doesnt pair the two.How it works
BspAndroidModulethat overridesbspBuildTargetDependencySourcesto show to the sources.jars that exist next to the jars that we pass in the classpathTweaks
resolvedMvnDeps0fromprivatetoprivate[mill]soAndroidModulehas access to it, in order to get the Sources JarsandroidResolvedMvnDeps(which is what we pass to compileclasspath), now needs to use a helper task that returnsSeq[UnpackedDep]], in order for the bsp module to find_.sourcesJarfrom that helper task (that exist in the same Task.dest with the ones in classpath)Notes
This may not be the best approach. Another solution could be to use GenIdea, and create xmls that link the two jars for each dep.
Screencast.From.2026-02-20.18-48-54.mp4