I like to treat my dependencies very strictly with gradle and jpms. This means most dependencies should be runtime only. However, springs javadoc organization makes this difficult. I find it very hard to tell if something comes from, eg. spring-core, spring-beans, spring-context, etc. With JPMS intellj isn't helpful with auto-imports if I haven't added the requires (their fault). However googling the class I'm looking for is also not helpful as the javadoc gives no indication of Jar.

Rhetorical question, what jar is @Component in https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/stereotype/Component.html . If I were following a thought on a JPMS best practice I would probably think it's in a non existent jar called spring-stereotype, otherwise I might think it's in spring-core. I think it's actually in spring-beans, I could be wrong because I don't actually have it pulled up in my IDE right now.

I see 3 options.

  • The URL should be something like /docs/spring-beans/current
  • the package-summary should include the Jar in the docs
  • every class should include the jar (excessive)

I actually think the url makes the most sense, but that might be more laborious than putting it in the package summary, which is also backwards compatible.

Comment From: bclozel

I don't think JPMS ever enforced a single package per JAR, nor that Java ever required to know on top of your head in which jar a class is zipped into. We're merely using here the Java standard tools for documenting and packaging our code. If you believe that this should be improved because of JPMS, you should get in touch with the Java team.

Comment From: xenoterracide

I don't think JPMS ever enforced a single package per JAR,

It doesn't, I'm saying that would be my guess based on naming recommendations and desirable package structures. It's obviously not correct.

nor that Java ever required to know on top of your head in which jar a class is zipped into

JPMS when using module-info does, arguably, require this though. Since only one jar may export a package, and classes have packages (I have no idea what goes on if you don't have a package even though that's possible, but doesn't apply to any use case here). This isn't about JPMS though, this is about finding the jar for inclusion with JPMS, or really for any dependency management; It includes gradle and maven too.

You've bundled all javadocs under one url. I'm moderately confident Java does not say that all javadoc for any number of jars should have one url.

Any dependency management system for java currently needs to say which jar to add at what scope. It's very difficult in spring land to determine what jar to set to compile time. JPMS just makes it worse because the 3rd party tooling doesn't aid as much.

So, do you have a better suggestion for determining which jar a class is in? in order to download and add it to the appropriate compile or runtime classpath?

Comment From: xenoterracide

Let me respond to this further with a question. I want to write a spring app, I need to include @Component all I have is java/javac, wget, and an internet connection. How do I figure out which jar on maven central to download to make this import?