Skip to content

Android: Show class sources in IDE#6856

Draft
souvlakias wants to merge 4 commits intocom-lihaoyi:mainfrom
vaslabs-ltd:android-include-sources-jar
Draft

Android: Show class sources in IDE#6856
souvlakias wants to merge 4 commits intocom-lihaoyi:mainfrom
vaslabs-ltd:android-include-sources-jar

Conversation

@souvlakias
Copy link
Contributor

@souvlakias souvlakias commented Feb 19, 2026

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/coursier and doesnt pair the two.

How it works

  • When unpacking an aar that we want to include in the classpath, also copy it's sources.jar in the extract directory
  • Create a BspAndroidModule that overrides bspBuildTargetDependencySources to show to the sources.jars that exist next to the jars that we pass in the classpath

Tweaks

  • Created a helper resolvedMvnJarSources in JavaModule to easily get all sources.jars
  • androidResolvedMvnDeps (which is what we pass to compileclasspath), now needs to use a helper task that returns Seq[UnpackedDep]], in order for the bsp module to find _.sourcesJar from 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.

import mill.javalib.bsp.BspModule
import mill.api.JsonFormatters.given

trait BspAndroidModule extends mill.javalib.bsp.BspJavaModule {
Copy link
Contributor

Choose a reason for hiding this comment

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

@experimental

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments