Review Request: Apache Maven Recipe for module-info and older projects
Robert Scholte
rfscholte at apache.org
Tue Oct 4 18:03:06 UTC 2016
Hi,
I've written a page[1] about the problem related to projects which need to
be compatible with pre Java9 versions, but also want to provide a
module-info file in case it is used in a Java 9 project. This is mainly an
issue for library builders, end-application builders can simply push
everything to Java 9.
Let me also explain why I didn't go for any other options:
- 1 execution-block to rule them all (maven-compiler-plugin magic): this
would mean you need to introduce several parameters for the compilation of
the module-info file. And we must assume they cannot always use the same
JDK. To keep enough strength for the end-user you must provide duplicates
of source/target/release, jdkToolchain, includes, excludes and maybe more.
The next issue is about result handling: the result of both javac calls
need to be merged, in all combinations of success and failure. In case of
failure you must provide the exact information. Whoever tries to implement
this just like I did must admit it results in ugly and hard controllable
code.
- 2 separate source folders could be a pattern, but probably not a
developer-friendly option. This also depends on what IDEs are going to do.
- Multimodule JAR: feels quite expensive to have a Maven MultiModule for
only one file. Also in this case we might need to wait and see what kind
of solutions IDEs have.
- auto-ignore module-info in case source/target/release < 9: I've decided
not to do this. Uninformed developers might think that the module-info is
automatically compiled. However, in the end the jar won't have the
module-info file. Better break the build and point them to the module-info
page[1]
I've written an integration test[2] matching this concept.
As said: this is mainly an issue for library builders. I expect that they
don't have a real issue with this small amount of extra configuration in
their pom. And this way they are still in full control.
Any comment is appreciated,
Robert
ps. .apt-files will be transformed to html with the maven-site-plugin as
part of every release.
[1]
http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/module-info.apt.vm
[2]
http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-compiler-plugin/src/it/MCOMPILER-275_separate-moduleinfo/
More information about the jigsaw-dev
mailing list