Repository navigation
fix(maven): fall back for Java sources outside the standard roots - #328
Conversation
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>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| // 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))) { |
There was a problem hiding this comment.
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>
|
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 ( |
Closes #327
What changed
This is step 1 of the issue, fail closed. A Maven module that has
.javaor.ktfiles outside every root DiffCI recognises now gets this blocker: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:build-helper-maven-pluginadd-test-sourceroot such assrc/it/java;<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):src/{main,test}/resources/, such as archetype templates and compiler-test inputs, which are already assets;.mvn/wrapper/MavenWrapperDownloader.java, which older Spring Initializr projects commit at the root.The Maven table in
docs/using-diffci.mdlists the new reason, with what to change to narrow it.Step 2 (reading
build-helper-maven-pluginroots sosrc/it/javanarrows 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:src/it/javaadded withbuild-helper-maven-plugin;src/integration/javain a module whose<parent>is an externalcom.acme:company-parent;src/it/kotlin.src/test/resourceswhenbuild-helper-maven-pluginis configured.src/main/resourcesandsrc/test/resources, plus the Maven wrapper's downloader;<testSourceDirectory>.If I revert the adapter change, the 3 fallback cases fail.
npm test: 1392 passed, 0 failed (the rest skipped).npm run typecheckandnpm run buildpass.Written with help from an AI assistant; I ran the checks above myself.