3

I read on Java 9 Modularity book:

Dependencies are always put on the module path, even when dependency isn't modularized yet.

[...] The most important changes made to Apache Maven for support of the Java module system are as follows:

  • Uses the modulepath during compilation
  • Supports a mix of explicit modules and automatic modules as dependencies

I'm looking at maven documentation and I cannot find this information anywhere.

Does maven by default add <dependencies> to the modulepath (only?) and if yes, after which maven version?

Also if the above is true is there a way to instruct maven to not use modulepath at all?

Marinos An
  • 9,481
  • 6
  • 63
  • 96
  • doesn't "after which maven version?" become insignificant, if compatibility is ensured? – Naman Jun 23 '20 at 11:52

1 Answers1

2

No, Maven puts dependencies to module path only for those Maven modules that have module descriptors (module-info.java). Non-modular Maven modules still put their dependencies to classpath.

You can run Maven with -X option to see exact command-line options that are passed to javac.

ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155
  • 1
    Well, the OP reminded me of https://stackoverflow.com/a/46571387/1746118 and I guess the unnamed modules aspect is missed out in this answer? – Naman Jun 23 '20 at 13:17
  • @Naman It looks like you're right. The dependencies that are not referenced in `module-info.java` (or transitively referenced) are put on classpath. However, I don't think this is super important here since we are talking about compile time. I can't imagine where that would make a difference. – ZhekaKozlov Jun 23 '20 at 13:47