Martin Desruisseaux opened MNG-8713 and commented
If a <source> element in POM does not provide any value for the <directory> element, the default value is currently defined as src/${scope}/${lang}. This default value provides the familiar src/main/java and src/test/java default directories. However, if the <source> element contains a <module> element, the module name must appear somewhere in the default directory name, otherwise the source code of multi-modular projects will collide.
Different conventions are possible:
- OpenJDK uses
src/${module}/ for the main code and a non-obvious directory pattern for the tests.
- Project Jigsaw: Module System Quick-Start Guide uses
src/${module}/ for main code and does not mention tests.
- junit5-modular-world uses
src/main/${module}/ for the main code and src/test/${module}/ for the test code. However, it also uses module-info.java in test code, which I would like to discourage.
- NetBeans Ant modular project uses
src/${module}/main for the main code and src/${module}/test for the test code.
I propose the NetBeans's convention with the addition of ${lang. The default directory would then be src/${lang}/${module}/${scope} when the <module> element is present and non-blank.
Alternative
If it is considered too premature to adopt a default directory name for modular project, we should at least throw an exception asking users to specify a directory explicitly if a <module> element is present. What we need to avoid is the status-quo, a default without module name.
Issue Links:
- MNG-8647 Set the default source directory to
src/${scope}/${lang} as per documentation
("is caused by")
Remote Links:
Martin Desruisseaux opened MNG-8713 and commented
If a
<source>element in POM does not provide any value for the<directory>element, the default value is currently defined assrc/${scope}/${lang}. This default value provides the familiarsrc/main/javaandsrc/test/javadefault directories. However, if the<source>element contains a<module>element, the module name must appear somewhere in the default directory name, otherwise the source code of multi-modular projects will collide.Different conventions are possible:
src/${module}/for the main code and a non-obvious directory pattern for the tests.src/${module}/for main code and does not mention tests.src/main/${module}/for the main code andsrc/test/${module}/for the test code. However, it also usesmodule-info.javain test code, which I would like to discourage.src/${module}/mainfor the main code andsrc/${module}/testfor the test code.I propose the NetBeans's convention with the addition of
${lang. The default directory would then besrc/${lang}/${module}/${scope} when the<module>element is present and non-blank.Alternative
If it is considered too premature to adopt a default directory name for modular project, we should at least throw an exception asking users to specify a directory explicitly if a
<module>element is present. What we need to avoid is the status-quo, a default without module name.Issue Links:
src/${scope}/${lang}as per documentation("is caused by")
Remote Links: