Martin Desruisseaux created MNG-8713:
----------------------------------------
Summary: Default source directory should include the module name
when present
Key: MNG-8713
URL: https://issues.apache.org/jira/browse/MNG-8713
Project: Maven
Issue Type: Improvement
Components: Core
Reporter: Martin Desruisseaux
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|https://openjdk.org/projects/jigsaw/quick-start] uses {{src/${module}/}}
for main code and does not mention tests.
*
[junit5-modular-world|https://github.com/junit-team/junit5-samples/tree/main/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.
h2. 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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)