Building jar targeting multiple Java versions, including 9
Alan Bateman
Alan.Bateman at oracle.com
Fri Aug 26 11:31:47 UTC 2016
On 26/08/2016 11:49, Robert Scholte wrote:
> Hi,
>
> I'm struggling with this issue too.
> I would have liked to see all the files under src/main/java, but since
> module-info cannot be compiled at the same time as the other files we
> need to do some extra things:
>
> Possible solutions:
> - Keep them all in the same folder but let Maven do 2 javac
> executions, auto-selecting the right files. I don't like this kind of
> magic and when the configuration of the maven-compiler-plugin becomes
> complex, there's a chance the magic is doing it wrong.
> - Introduce an extra sourcefolder. This is by far the most clean
> solution and with good documentation we should be able to explain this.
> I've created MCOMPILER-275[1] to implement this new feature.
The intention is that the module-info.java be in the root directory and
I could imagine it confusing developers if they have to edit it in a
separate source tree. I also worry that it would give the impression
that a separate source tree is the right way to structure the source
code. I'm also not sure how it would work in the IDE. Then we have the
issue that the src and output tree no longer matching, that could be
confusing too. Then we have the question of projects targeting >= JDK 9
where I assume you would have the module-info.java in the root directory.
How difficult would it be for the compiler plugin to special case
module-info.java when compiling for an older release? Would there be
something in the POM to indicate whether the project produces a module,
as a modular JAR?
-Alan.
More information about the jigsaw-dev
mailing list