Can SBT use the java 11 module path for project depencencies?

Viewed 306

I have used SBT to build a pure-java project. This project consists of multiple modules, and projectB depends on projectA. Now after switching to JDK 11, this dependency should be modeled not via classpath but via module path. Is it possible to tell SBT that module depencencies must be resolved via module path instead of the classpath? Basically I have set up a inter-(sbt-)module depencencs that says projB.dependsOn(projA) - so can I tell SBT somehow to put this depencency on the javac module-path instead of using the classpath? I see currently no way of doing that.

EDIT: Further analysis showed that I needed also to use normal library depencencies (from libraries on a nexus repository) as module depencencies. So the next question would be - how can I treat these library depencencies as module depencencies in SBT?

I do know that SBT is a scala build tool, and that it is something of a stretch to use it for a java-only project, but I use SBT for other (scala-)projects, and I do not want to introduce too many different build tools, until I really have to. So - is there a sbt-level solution for this?

EDIT: To clarify the issue - the project in question is a kind of open-source library which we modified. The SBT build file is from our organization, so I have to maintain it. The project switched to using module-info classes, and it depends on other (binary-only) libraries via module path, if you include module-info.java in the compilation, that is.

So in our SBT build I have to use the module path for some of the external library depencencies. Also the SBT-subprojects have dependencies on each other, i.e. we also have to use the module path for that. Is there a way to tell SBT that:

  • This library must be on the module path, and not on the classpath
  • This project dependency must be on the module path, and not via classpath?

That is the core of the question. I may be able to write a plugin for the first problem (having not libraryDepencencies, but modularLibraryDepencencies for example) - but I do not yet know how I could handle the second part (tell a project that project depencencies must be on the module path and not on the class path).

0 Answers
Related