Hi All, is there a way to fetch sources and java-d...
# general
m
Hi All, is there a way to fetch sources and java-docs with
jvm_artifact
?
h
Not my general area of expertise, but FWIW I don't see support for Maven-style classifiers in the target type, but I do see it in the underlying coursier resolver handling code.
What would you want to do with these sources and docs jars?
Just downloading them for you to point your IDE at might be straightforward, but compiling a downloaded source JAR might be harder
m
This is only for IDE purpose. when you navigate through project you want to have sources for libraries. It shouldn't be very difficult to add this functionality since coursier can do it.
here is bazel rule that is similar to
jvm_artifact
we could check how they did it.
h
How would you expect this to work from a user perspective? What command would you expect to run to download these, and where should they go? (I suspect they should go to
dist
, so maybe this is an
export
subcommand?)
m
similarly to bazel rule I would expect that you have configuration that indicates whether or not you would like to fetch sources and/or java-docs.
Copy code
maven_install(
    artifacts = [
        "junit:junit:4.12",
        "androidx.test.espresso:espresso-core:3.1.1",
        "org.hamcrest:hamcrest-library:1.3",
    ],
    repositories = [
        # Private repositories are supported through HTTP Basic auth
        "<http://username:password@localhost:8081/artifactory/my-repository>",
        "<https://maven.google.com>",
        "<https://repo1.maven.org/maven2>",
    ],
    fetch_sources = True
)
I'm completely new to pants so right now to pull deps in my toy project I use
pants generate-lockfiles
so I would expect that when I update my dependencies sources are fetched too (at best effort because some libraries do not export them). Ideally sources should be stored next to the lib files so when you import your project with BSP to intellij and navigate to class from external jar when you click choose sources it should be right there. obviously sources for external libs should not be included in final package.
h
That bazel rule runs when you invoke ... something on the command line. Something has to trigger that fetch. What would you want that to be? Is it a byproduct of downloading the binary deps? Or is there an explicit command to export these?
generate-lockfiles
doesn't exactly "pull deps" - it generates a lockfile. Deps are fetched on demand, based on that lockfile.
Which is possibly not what you want with sources, you probably want to preemptively download them all
m
as I said I'm running this command to get result probably this is suboptimal way because I don't know pants at all. In bazel I use specific command/goals to pull deps and generate lock file so it will be fine too. I run it from command line.
but to be clear I don't want to have separate commands to pull dependencies and sources.
I checked BSP spec and probably you could put sources in separate folder and implement this request https://build-server-protocol.github.io/docs/specification/#buildtargetdependencysources-request
@happy-kitchen-89482 I looked into the code and it seems that there is already stub method for
dependencySources
request. Maybe better idea would be to fetch sources only when bsp project is refreshed - when DependencySourcesRequest is sent. coursier_fetch.py could be used to fetch those additional sources. what do you think?