Re: Compiler plugin & JDK 9 & classpath/modulepath question

2016-11-11 Thread Robert Scholte
On Wed, 09 Nov 2016 13:24:02 +0100, Matej Novotny   
wrote:



Hello,

I was recently trying the following scenario with JDK 9 and mvn compiler  
3.6.0:
A new Maven project, with module-info, running with JDK 9, having a  
dependency on one other non-modular project (Weld SE in this case).
Feel free to inspect it on GH ->  
https://github.com/manovotn/JDK9Playground


Now compiling this with debug mode showed me that Maven puts the  
dependency onto module-path of the project.

This means JDK 9 will turn this into automatic module.
So I ended up adding entries (`requires` formulas) into module-info.java  
on the one dependency I have there.


I managed to make it compile in the end, but I was wondering about the  
following:
=> Is there a way to tell Maven, that I want to add this dependency (and  
all it brings in transitively) to CLASSPATH instead of module path?
  - that would effectively mean there would be no automatic module (so I  
wouldn't need to declare it in module-info) and instead if would "fall  
back" to unnamed module (=searching classpath)


Right now there's no simple way to do that. While working on the  
modulepath I assumed that once people add the module-info, that they would  
also use auto modules by default to get a 100% pure module instead a  
hybrid.
I've talked with the jigsaw team and there are still some issues with  
transitive (jigsaw) modules, which might effect the current implementation.


I think it is good to track this, so could you add a jira issue at  
https://issues.apache.org/jira/browse/MCOMPILER ?




 => Is there a way for Maven to automatically populate your module-info  
with entries regarding automatic modules? Or at least some kind of a  
detection for which ones do I need?


This is the ever returning question :) So in Java 9 jdeps is capable to  
generate a module-info template for you based on the code. It exports all  
packages, defines the requires and is often capable to detect which ones  
should be transitive, but is cannot detect the optionals. Be aware: this  
is a template, something to start with and which you MUST adjust. It is  
not an incremental tool.


Maven might create the "requires" part and know the optionals, but it  
cannot know about the transitivity (because it jigsaw transitive has a  
different definition than Maven transitive. They're still looking for a  
better keyword to prevent confusion, so any suggestion is welcome).


However, both Maven and the Jigsaw team need to come with a clear  
explanation, because dependencies and modules have different purposes.
I'll give it a try: dependencies resolve into coordinates of multiple  
files which will be added to the classpath (and with Java9 it could also  
be the module path). Having too much dependencies is not an issue, it is  
simply another jar on the path.
The "requires" of the module-info is there to enforce that certain files  
are available, either at compile time or at runtime.
So you can compare this as 2 partly overlapping circles. For the larger  
part is could be possible, but especially the parts that don't overlap are  
hard (impossible?) to identify.
It is very easy to add dependencies, but you never want any irrelevant  
"requires" inside your module-info.


I hope you understand that the purpose of dependencies and required  
modules are very different. Any attempt to try to solve this with magic is  
a potential failure. Any generated file must always be validated by the  
developer, there's no 1 to 1 translation.


Robert




Many thanks
Matej

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Compiler plugin & JDK 9 & classpath/modulepath question

2016-11-09 Thread Matej Novotny
Hello,

I was recently trying the following scenario with JDK 9 and mvn compiler 3.6.0:
A new Maven project, with module-info, running with JDK 9, having a dependency 
on one other non-modular project (Weld SE in this case).
Feel free to inspect it on GH -> https://github.com/manovotn/JDK9Playground

Now compiling this with debug mode showed me that Maven puts the dependency 
onto module-path of the project.
This means JDK 9 will turn this into automatic module.
So I ended up adding entries (`requires` formulas) into module-info.java on the 
one dependency I have there.

I managed to make it compile in the end, but I was wondering about the 
following:
  
 => Is there a way to tell Maven, that I want to add this dependency (and all 
it brings in transitively) to CLASSPATH instead of module path?
  - that would effectively mean there would be no automatic module (so I 
wouldn't need to declare it in module-info) and instead if would "fall back" to 
unnamed module (=searching classpath)

 => Is there a way for Maven to automatically populate your module-info with 
entries regarding automatic modules? Or at least some kind of a detection for 
which ones do I need?


Many thanks
Matej

-
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org