Skip to content

[MCOMPILER-569] Document implicitly compiled excluded sources - #1092

Open
wilx wants to merge 2 commits into
apache:maven-compiler-plugin-3.xfrom
wilx:issue-778-excludes-doc
Open

[MCOMPILER-569] Document implicitly compiled excluded sources#1092
wilx wants to merge 2 commits into
apache:maven-compiler-plugin-3.xfrom
wilx:issue-778-excludes-doc

Conversation

@wilx

@wilx wilx commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Clarify the compile and testCompile exclusion parameter documentation: an excluded source such as module-info.java may still be compiled when javac finds it implicitly. Link both parameters to <implicit>, which can be set to none to suppress class generation for implicitly referenced sources.

This documents the distinction between the plugin's explicit source filtering and javac's implicit source discovery.

Fixes #778

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MCOMPILER-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MCOMPILER-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

Clarify that excluded sources may still be compiled implicitly and link the compile and testCompile exclusion parameters to the implicit option.

Fixes apache#778
@wilx
wilx marked this pull request as ready for review July 28, 2026 19:03
@elharo
elharo requested a review from Copilot July 28, 2026 20:35

/**
* A list of exclusion filters for the compiler.
* A file such as {@code module-info.java} may still be compiled if it is implicitly referenced by the compiler,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't understand what "implicitly referenced by the compiler" means.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is described in https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#searching-for-module-package-and-type-declarations. The relevant lines are

When compiling code for a module, the compiler also needs to have available the declaration of that module.
A successful search may produce a class file, a source file, or both. If both are found, then you can use the -Xprefer option to instruct the compiler which to use.
If a search finds and uses a source file, then by default javac compiles that source file. This behavior can be altered with -implicit.

Feel free to suggest better wording.

@elharo elharo changed the title [MCOMPILER-569] - Document implicitly compiled excluded sources [MCOMPILER-569] Document implicitly compiled excluded sources Jul 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Documents that excludes/testExcludes only affect the plugin’s explicit source filtering, and that javac may still compile excluded files when it discovers them implicitly (e.g., module-info.java), pointing users at the implicit setting.

Changes:

  • Clarify excludes Javadoc to mention implicit compilation by javac
  • Clarify testExcludes Javadoc similarly
  • Add a reference to AbstractCompilerMojo#implicit from both parameters

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java Adds Javadoc clarifying that excluded sources can still be compiled implicitly and references implicit.
src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java Mirrors the same clarification for test compilation excludes and references implicit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +112 to +115
* A file such as {@code module-info.java} may still be compiled if it is implicitly referenced by the compiler,
* even if it has been excluded.
*
* @see AbstractCompilerMojo#implicit
Comment on lines +99 to +102
* A file such as {@code module-info.java} may still be compiled if it is implicitly referenced by the compiler,
* even if it has been excluded.
*
* @see AbstractCompilerMojo#implicit
Explain that exclusions only affect sources passed explicitly by the plugin and that javac can still discover sources through the source path.
@wilx

wilx commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

I have pushed a change with different wording.

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.

3 participants