Skip to content

[MNG-8713] Default source directory should include the module name when present #9589

@jira-importer

Description

@jira-importer

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:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions