On Tue, 24 Apr 2018 13:00:27 +0200, Martin Desruisseaux <[email protected]> wrote:

Hello all

The Maven folder structure differs from the folder structure expected by
standard javac and javadoc tools:

* *Maven:* <maven-module-artifactIDs>/src/main/java/<packages>/<classes>
  * *Java:* <jigsaw.module.names>/<packages>/<classes>

I understand that Maven can still build a Java 9 project by compiling
each module with a separated invocation of javac, and I have seen the
"do and don't with Java 9" recommendation to not change the Maven folder
structure (slide 38 of [1]). Nevertheless I'm considering to try
changing some projects folder structure to match the Java 9 convention.
Reasons are:

  * We now have two conflicting conventions: Maven and Java 9. I'm
    tented to choose the one used by the most "fundamental" tool for the
    reasons below.

I don't think they are conflicting. Java has no defaults for the directories. What you see at conferences is that the people from Oracle choose not to work with a buildtool like most developers do (this might be a political statement; what if they were using Maven during their talks...). You see they have their own folder structure which matches their work best.

The reason to add the module-name as an extra directory in front of the sourcefolder is only interesting when compiling multiple modules at once, so you can separate these modules from each other. This model doesn't fit well, because every module is represented by a jar, every jar need to have a groupId + artifactId + version. Saying it the other way around: with a pom.xml you can only generate one module. Hence there's no need for the extra module name. Maven just works with src/main/java/module-info.java


  * I have not yet been able to generate aggregated Javadoc for a
    project following Maven directory structure. Even when using javadoc
    on the command-line, the tools insists for having a directory
    structure matching the Java 9 conventions (maybe I have not found
    the right command-line options yet).

I haven't tried this yet. But first step would indeed be the commandline. If you don't succeed here, use I'd suggest to send an e-mail (http://mail.openjdk.java.net/mailman/listinfo/javadoc-dev) and maybe that can be good input for the plugin.

  * Even if the above-cited problem can be solved by appropriate
    command-line options, complying with Java 9 conventions would make
    easier to use javac, javadoc or other tools on the command line for
    multi-modules projects (even if Maven still the primary build tool,
    I sometime want to do experiments manually).

This is a personal choice. If this is a requirement for you, maybe Ant fits better.

  * Even if Maven is the "official" build tools in a project, I like to
    provide NetBeans project files (the Ant script generated by
    NetBeans) for convenience. I know that NetBeans has excellent Maven
    integration, but NetBeans projects are still faster to build,
    execute and debug, allow to configure hints, to customize
    spell-check entries, to specify the copyright header in new files,
    etc. So I develop with NetBeans and launch Maven only for
    verification before to commit or for deployments/releases. But
    NetBeans 9-snapshot multi-modules project seems to require
    compliance with Java 9 conventions.

Rémi Forax proposes another build tools with a directory structure
adapted to Java 9 conventions [2]. Basically instead of
"<module>/src/main/java" he uses "src/main/java/<module>". Has anyone
considered to use such directory structure in a Maven project? I realize
that it would requires customizing the pom.xml files and that it put the
main source code (src/main/java) and the test (src/test/java) further
apart (main and test no longer in the same module directory). I'm having
hesitation about whether the advantages would be worth the inconvenient.

As said before, every module needs its own pom.xml. It would require a complete new architecture of Maven to make this possible, where a single Maven project can create multiple jars, all with their own unique pom. It is very unlikely that this will be implemented, unless the community really wants it and there's enough benefit to do so.


Related question: would Maven consider to support an alternative
directory structure convention more "naturally" compatible with Java 9
conventions (meaning: allowing a modular "Hello world" to be compilable
with a minimal set of javac options)?

    Regards,

        Martin

[1] https://fr.slideshare.net/RobertScholte/the-dos-and-donts-with-java-9-devoxx-2017
[2] https://github.com/forax/pro-demo/#a-simple-modular-application


thanks,
Robert

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to