Skip to content

[java] automatic-module-name header added for pmd-core - #6168

Open
magwas wants to merge 4 commits into
pmd:mainfrom
magwas:feature/automatic-module-name
Open

magwas wants to merge 4 commits into
pmd:mainfrom
magwas:feature/automatic-module-name

Conversation

@magwas

@magwas magwas commented Oct 25, 2025 •

Copy link
Copy Markdown

Describe the PR

Adds Automatic-Module-Name header to the MANIFEST.MF of pmd-core
Had to exclude pmd.cache from javadoc, as there are no classes there, but checked that subpackages get included in the javadoc.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • [x ] Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@zbynek

zbynek commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

Don't you need to do this for pmd-java as well?

@magwas

magwas commented Oct 28, 2025

Copy link
Copy Markdown
Author

Sure. I will update the PR shortly.

@adangel

adangel commented Oct 29, 2025

Copy link
Copy Markdown
Member

Thanks for the PR. However, if we do this, we should do it consistently for all modules. And we can't change it later without breaking compatibility.

Regarding the module name to use - I found this answer: https://stackoverflow.com/questions/43192741/how-should-i-name-my-java-9-module

So we should probably use the following names:

  • pmd-core: net.sourceforge.pmd.core (that's a bit weird currently, ideally the module name would be the same as the root package)
  • pmd-java: net.sourceforge.pmd.lang.java
  • ...

It's maybe worth to update https://docs.pmd-code.org/latest/pmd_projectdocs_decisions_adr_3.html#project-structure-and-java-base-packages-names (https://github.com/pmd/pmd/blob/main/docs/pages/pmd/projectdocs/decisions/adr-3.md) as well to define and mention module names (and the mapping from maven modules to java modules).

We already anticipated that (under consequences):

Clearly defining the API PMD provides will help to further modularize PMD using the Java Module System.

But it was not requested yet. Now you are the first one to request this...

Comment thread pmd-core/pom.xml
<configuration>
<!-- overrides the configuration from parent pom: we have here no offline links yet -->
<offlineLinks combine.self="override"></offlineLinks>
<excludePackageNames>net.sourceforge.pmd.cache</excludePackageNames>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to exclude pmd.cache from javadoc, as there are no classes there, but checked that subpackages get included in the javadoc.

That's strange, maybe a bug in javadoc? We have at least a package-info.java file there, so we should not run into such a problem, should we?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand if module-info.java exist, javadoc goes into module mode and requires classes to be in the package.
Probably package-info.java does not count as a class.

@magwas

magwas commented Oct 29, 2025

Copy link
Copy Markdown
Author

Regarding module names:
I neither like reverse dns based module names, and I do not use them in my projects. Spring also simply uses names like spring.context and spring.core. I used the generated module name for your packages (s/-/./ of artifactId).
But it is your project, I happy to set whatever you decide, so I go with the names you prescribe.

Names are important, so I ask you to confirm your decision, probably after discussing it in the team.

I got the request that I should add an automatic-module-name header to all modules creating jar artifacts. OK.
I assume in case of both production and test jar is created, the test jar should have '.tests' appended to the main module name.

I found adr-3.md in the source, so I can change it. I assume there is some decision-making process related to it. What kind of input you need from me? Draft changes in this pull request?

In the meantime I assume drafting changes to adr-3 is the way to go, so I will shortly add a commit with that.

@adangel adangel added this to the 7.19.0 milestone Oct 30, 2025
@magwas

magwas commented Oct 31, 2025

Copy link
Copy Markdown
Author

The scala artifact naming convention colludes with the java module system. As an example parsers_2.13-4.14.1.jar (a dependency) would become automatic named as parsers.2.13, which is not a valid java module name. Adding automatic-module-name to that would solve the situation, but I guess that for stable names there should be a naming convention in scala for module names. I checked the latest parser, and found neither automatic-module-name header, nor module-info.
In this situation I guess it is a safe bet not to give an automatic module name to these jars, as we cannot safely guess what will be the name according to some assumed future convention, and it seems that the scala ecosystem is just ignoring the java modularization effort of jdk architects (which I can wholeheartedly understand).

scala and visualforce uses artifact naming conventions clashing with the module system,
and their ecosystem does not have module naming convention, so they got no header for now
@magwas
magwas force-pushed the feature/automatic-module-name branch from e678237 to 6ee748d Compare November 1, 2025 01:49
@pmd-actions-helper

Copy link
Copy Markdown
Contributor

Documentation Preview

No regression tested rules have been changed.

(comment created at 2025-11-01 11:01:07+00:00 for 6ee748d)

@adangel adangel modified the milestones: 7.19.0, 7.20.0 Nov 24, 2025
@adangel adangel modified the milestones: 7.20.0, 7.21.0 Dec 28, 2025
@adangel adangel modified the milestones: 7.21.0, 7.22.0 Jan 29, 2026
@adangel adangel modified the milestones: 7.22.0, 7.23.0 Feb 26, 2026
@adangel adangel modified the milestones: 7.23.0, 7.24.0 Mar 24, 2026
@adangel adangel modified the milestones: 7.24.0, 7.25.0 Apr 24, 2026
@adangel adangel removed this from the 7.25.0 milestone May 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[java] Warning when used as dependency in modularized project

3 participants