What do I need to build JDK 9 project with non-modular dependencies using Maven
<p>I have a simple Java 9 SE project with one dependency on a non-modularized project (chose Weld SE for this example) and I am trying to build it with Maven (<code>clean install</code>).In order for Java 9 to kick in, I have added <code>module-info.java</code>. Originally, this file only contained module name and had no <code>requires</code> formulas.</p>

<p>Please bear in mind that my sole dependency is NOT a modular project, therefore I presumed Maven will put in the classpath (not module-path) and hence it will end up in the <code>unnamed module</code> as described in <a href="http://openjdk.java.net/projects/jigsaw/spec/sotms/#unnamed-modules" rel="noreferrer">State of the modular system</a>.</p>

<p>Now, my Maven version is 3.3.9 and I am aware that I need to use Maven compiler plugin in version 3.6, as <a href="https://maven.apache.org/plugins/maven-compiler-plugin/examples/module-info.html" rel="noreferrer">described here</a> Of course I have downloaded JDK 9 EA build with jigsaw and set Maven to use that.</p>

<p>If I build my project without <code>module-info.java</code>, everything works, stuff is added to classpath and build succeeds. I suppose Maven just sticks to the old ways as long as you leave out that file.</p>

<p>However building it <em>with</em> <code>module-info.java</code> tells me that the classes from my dependency cannot be found on the classpath. So I ran Maven in debug mode (with -X) and indeed - <strong>all jars are under module-path and classpath is empty</strong>. This effectively means that all my dependencies are <strong>transferred into <a href="https://github.com/manovotn/JDK9Playground/blob/master/src/main/java/module-info.java" rel="noreferrer">automatic modules</a></strong> and I need to declare them in <code>module-info.java</code>.</p>

<p>Once I declare the <a href="https://github.com/manovotn/JDK9Playground/blob/master/src/main/java/module-info.java" rel="noreferrer">automatic module requirements</a>(link to projects's <code>module-info</code>), <strong>I am able to build it on JDK 9</strong>. But it is kind of messy - my only <code>pom.xml</code> dependecy is on <code>weld-se-core</code>, yet my <code>module-info</code> requires me to declare <em>a lot more requirements</em> for compilation to pass.</p>

<p>Here is a whole <a href="https://github.com/manovotn/JDK9Playground" rel="noreferrer">GitHub project</a> where all this can be observed.</p>

<p>So my questions are: </p>

<ol>
<li><em>Can I tell Maven to put some artifacts on classpath if I know they are not modularized? So that I can avoid the <code>automatic module</code> and the need to declare them?</em></li>
<li><em>If I stick with <code>automatic module</code>, can I tell Maven to somehow transitively allow anything my dependency needs to bring in? E.g. other parts of Weld, CDI API etc.</em></li>
<li><em>What is the actual reason, why I need to state, that my project <code>requires</code> modules, which I <strong>do not use directly? E.g. <a href="https://github.com/manovotn/JDK9Playground/blob/master/src/main/java/module-info.java#L6" rel="noreferrer"><code>weld.environment.common</code></a></em></strong></li>
</ol>