Building jar targeting multiple Java versions, including 9
uschindler at apache.org
Fri Aug 26 11:48:31 UTC 2016
I know it is a bit of strange request. Maybe this could also be a solution: How about implementing a Maven plugin that generates a module-info.class file out of box using ASM 6.0 without any source code - just by configuration? Or maybe use the ANTLR module-info.java syntax and write e very simple separate compiler? Or alternatively: Could the module-info.java compiler be separated from javac, so it can be executed as a separate tool, maybe shipped as a separate JAR file like the JRT filesystem?
Another thing that we could allow is to execute Javac with older source/release/target setting, but add an extra flag to allow it compiling module-info.java without complaining?
uschindler at apache.org
ASF Member, Apache Lucene PMC / Committer
> -----Original Message-----
> From: jigsaw-dev [mailto:jigsaw-dev-bounces at openjdk.java.net] On Behalf
> Of Alan Bateman
> Sent: Friday, August 26, 2016 1:32 PM
> To: Robert Scholte <rfscholte at apache.org>; jigsaw-dev at openjdk.java.net
> Subject: Re: Building jar targeting multiple Java versions, including 9
> 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 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?
More information about the jigsaw-dev