score:2

how do i do that?

in the way you just described, having multiple sbt modules.

i have to publish these modules separately?

you usually have a single root module that aggregates all the other modules like core and extras (which would depend on core) and you publish root which will transitively publish the others.

can they have different versions?

afaik there is nothing preventing you to have different versions... but, i have never seen a library doing this, when the versions must not be the same they are in separate github repos (which makes sense, since at the end you will probably have an automated process that publishes all of them at once)

also, it's not clear to me if library user should only include "feature module" which would transitively include core module.

if you follow the previous schema, the pom of extras will mention core thus users of your library can only import extras and their build tools will transitively fetch core
however, whenever or not they want to do that (or that they consider that a best / bad practice) rather than also including core explicitly is up to them. this topic is somewhat controversial, although most people agree that if you explicitly use something from a library then you must explicitly depend on it; see: https://github.com/cb372/sbt-explicit-dependencies


Related Query

More Query from same tag