[ 
https://issues.apache.org/jira/browse/MNG-8713?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17948175#comment-17948175
 ] 

Martin Desruisseaux commented on MNG-8713:
------------------------------------------

Both approaches are technically possible. Reminder: the pull request does not 
change the convention of non-modular projects or projects that do not use the 
[module source 
hierarchy|https://docs.oracle.com/en/java/javase/24/docs/specs/man/javac.html#module-source-hierarchy]:
 {{src/main/java}} is not flipped to {{src/java/main}}. Only for projects that 
use the module source hierarchy, we would "flip" from _(nothing that exist 
currently in Maven)_ to {{src/java/org.my.module/main}}.

The reason for putting {{${lang}}} before {{${module}}} is because the module 
names tend to be language-dependent. For example, Java uses URL domain names 
(e.g. {{org.apache.maven}}) while Python uses [shorter module 
names|https://www.programcreek.com/python/index/module/list], without {{org}} 
or {{com}} prefix. if a Maven subproject mixes Java and Python modules, placing 
the modules of the two languages in the same directory is confusing.

The reason for putting {{${scope}}} after {{${module}}} is for grouping 
together the files related to each module. This is the same division as Maven 
subprojects (previously named "modules"): each subproject contains main, test, 
resource and pom.xml files. Likewise, each Java module would contain its own 
main, test, resource files, with module-info somewhat playing the role of 
pom.xml. In other words, we are still splitting the projects in modules, but 
shifting from a world where modules are managed by Maven to a world were 
modules are managed by Java.

There is precedent: {{${module}/${scope}}} is the directory layout of 
NetBeans's Ant modular project, and also of [Christian Stein's 
blog|https://github.com/sormuras/java-module-patching?tab=readme-ov-file#directory-layout-structure]
 except for {{${lang}}}.

> 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
>            Priority: Major
>
> 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)

Reply via email to