Skip to content

Filter .mvn/extensions.xml also for a project without a POM - #759

Open
slawekjaranowski wants to merge 1 commit into
apache:masterfrom
slawekjaranowski:filter-extensions-for-pom-less-project
Open

slawekjaranowski wants to merge 1 commit into
apache:masterfrom
slawekjaranowski:filter-extensions-for-pom-less-project

Conversation

@slawekjaranowski

Copy link
Copy Markdown
Member

The problem

A project run by the plugin can be denoted either by a path to its pom.xml or merely by a path to its base directory - the latter for a project which has no POM at all (scanProjectsDirectory() / collectProjects() keep the bare directory in that case, and runBuild() then invokes Maven on the directory).

The filtering loop in cloneProjects() assumed the first form only:

File pomFile = new File(cloneProjectsTo, projectPath);
...
File baseDir = pomFile.getParentFile();
File mvnDir = new File(baseDir, ".mvn");

For a POM-less project projectPath is the project directory, so getParentFile() points at its parent - the clone root. The plugin then looks for <cloneProjectsTo>/.mvn/extensions.xml instead of <cloneProjectsTo>/<project>/.mvn/extensions.xml, and the project's own .mvn/extensions.xml is never interpolated: the @...@ tokens are passed to Maven verbatim. The failure is silent - no warning, no error.

The fix

Determine the base directory the same way runBuild() does - the project directory itself when the path denotes a directory, its parent otherwise. The now redundant mvnDir.isDirectory() check is dropped (extensionsFile.isFile() already implies it) and pomFile is renamed to projectFile, since that path is not always a POM - which is what caused the bug in the first place.

Tests

The existing filtering-extensions IT gains a second test project without a pom.xml (only .mvn/extensions.xml with @project.*@ tokens, plus invoker.properties with invoker.goals = --version so Maven can run POM-less). Verified that the IT fails without the production change and passes with it.

On the way the IT verify script has been converted from BeanShell to Groovy - Groovy assertions report what failed on their own, so the explicit System.out reporting and the try/catch/return true scaffolding are gone (75 lines -> 35).

@slawekjaranowski slawekjaranowski added the enhancement New feature or request label Sep 14, 2026
@slachiewicz
slachiewicz removed their request for review September 17, 2026 19:22
@slawekjaranowski slawekjaranowski self-assigned this Sep 17, 2026
@slachiewicz
slachiewicz removed their request for review September 20, 2026 13:43
A project can be denoted either by a path to its pom.xml or merely by a path
to its base directory - the latter for a project which has no POM at all.
The filtering loop in cloneProjects() assumed the former and derived the
project base directory with getParentFile(), which for a POM-less project
points at the parent of the project directory. As a result .mvn/extensions.xml
of such a project was never interpolated and the @...@ tokens were passed to
Maven verbatim.

Determine the base directory the same way runBuild() does.

The filtering-extensions IT covers a project without a POM now. Its verify
script has been converted from BeanShell to Groovy on the way - Groovy
assertions report what failed on their own, so the explicit System.out
reporting and the try/catch/return true scaffolding are no longer needed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

# Conflicts:
#	src/it/filtering-extensions/verify.groovy
@slawekjaranowski
slawekjaranowski force-pushed the filter-extensions-for-pom-less-project branch from 8aa7779 to 64a8874 Compare September 29, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant