Skip to content

fix(maven): fall back for Java sources outside the standard roots - #328

Merged
adityankale190895 merged 2 commits into
DiffCI:mainfrom
sarankumar1325:fix/327-maven-unknown-roots
Nov 19, 2026
Merged

adityankale190895 merged 2 commits into
DiffCI:mainfrom
sarankumar1325:fix/327-maven-unknown-roots

Conversation

@sarankumar1325

@sarankumar1325 sarankumar1325 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #327

What changed

This is step 1 of the issue, fail closed. A Maven module that has .java or .kt files outside every root DiffCI recognises now gets this blocker:

Maven <module>/pom.xml: Java sources outside the standard roots require full validation

The recognised roots are src/main/{java,kotlin}, src/test/{java,kotlin} and the module's resolved <testSourceDirectory> from #317. One check covers both cases in the issue, plus any plugin DiffCI doesn't know about:

  • a build-helper-maven-plugin add-test-source root such as src/it/java;
  • a <testSourceDirectory> that a company parent POM outside the repository sets.

These are not counted as stray sources, so they don't trigger a fallback (unless the module's POM configures build-helper-maven-plugin, which can add a folder under resources as a source root):

  • files under src/{main,test}/resources/, such as archetype templates and compiler-test inputs, which are already assets;
  • the Maven wrapper's .mvn/wrapper/MavenWrapperDownloader.java, which older Spring Initializr projects commit at the root.

The Maven table in docs/using-diffci.md lists the new reason, with what to change to narrow it.

Step 2 (reading build-helper-maven-plugin roots so src/it/java narrows instead of falling back) is left for a follow-up, as the issue allows.

Tests

The new tests are in tests/repo/maven-test-source-directory.test.ts, using the same reactor fixture as #317:

  • Falls back, for both a library change and a change to the stray file itself:
    • src/it/java added with build-helper-maven-plugin;
    • src/integration/java in a module whose <parent> is an external com.acme:company-parent;
    • a Kotlin file under src/it/kotlin.
  • Falls back for Java under src/test/resources when build-helper-maven-plugin is configured.
  • No blocker:
    • Java under src/main/resources and src/test/resources, plus the Maven wrapper's downloader;
    • files under a resolved <testSourceDirectory>.

If I revert the adapter change, the 3 fallback cases fail. npm test: 1392 passed, 0 failed (the rest skipped). npm run typecheck and npm run build pass.

Written with help from an AI assistant; I ran the checks above myself.

A module with .java or .kt files outside src/main/{java,kotlin},
src/test/{java,kotlin} and its resolved <testSourceDirectory> now gets the
blocker 'Maven <pom>: Java sources outside the standard roots require full
validation'. This covers a build-helper-maven-plugin test root such as
src/it/java and a test root set by a parent POM outside the repository.
Resources and the Maven wrapper's downloader are not counted.

Closes DiffCI#327

Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T12:01:55.630261Z 869349c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 869349c48c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/repo/adapters/maven.ts Outdated
// Resources (archetype templates, compiler-test inputs) and the Maven wrapper's downloader are not sources.
const known = new Set(sources);
if (owned.some(file => /\.(?:java|kt)$/.test(file) && !known.has(file) &&
!/\/src\/(?:main|test)\/resources\//.test("/" + file) && !/(?:^|\/)\.mvn\//.test(file))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the blocker for sources explicitly added from resources

When a Maven module uses build-helper-maven-plugin to add a source root under src/main/resources or src/test/resources, this exception suppresses the blocker even though Maven compiles those files. They are then classified as assets rather than sources, so a changed test file there can be omitted from test selection without requiring full validation.

Useful? React with 👍 / 👎.

…ugin is configured

build-helper-maven-plugin can add a folder under src/{main,test}/resources as a
source root, so Java there is only exempt when the POM doesn't configure it.

Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
@adityankale190895
adityankale190895 merged commit 722ff89 into DiffCI:main Nov 19, 2026
13 checks passed
@adityankale190895

Copy link
Copy Markdown
Member

Thanks @sarankumar1325, merged: the Maven fallback for sources outside the standard roots is in. If you want to talk through a change before you open it, or just chat about CI, we have a Discord now: https://discord.gg/vAftSVeYgk (#contributing).

adityankale190895 added a commit that referenced this pull request Nov 19, 2026
Moves the CLI's Core pin to 722ff89 so #328 and #332 ship.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: adityankale190895 <adityankale1995@gmail.com>
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.

Maven: Java tests outside the standard roots are skipped instead of falling back

2 participants