Read the Test Resources settings of the application mn:run selects from a reactor #1737
Reviewed as part of the combined reload-stack review for micronaut-core#13654. This pass covered selected-project configuration, parameter reset and Test Resources initialization, including interactions with the later linked changes.
No additional actionable finding in this PR in this pass.
This is a static/integration review, not an approval or a claim that the full JVM/native, build-tool and broker/database test matrix passed. Focused reproductions were used for the Kotlin metadata, Python imported-binding and Java compilation-retry findings elsewhere in the stack.
 Quality Gate failed
Failed conditions
 75.2% Coverage on New Code (required ≥ 80%)
 1 New Critical Issues (required ≤ 0)
<!-- sqra:qg_revision=ac540a9b9853234499f5d69cca61c7fd31ff81fdf3ec85c54dc91578333e10c5 -->
<!-- sqra-placement-anchor -->
See analysis details on SonarQube Cloud
 Catch issues before they fail your Quality Gate with our IDE extension  SonarQube for IDE
Nit: MojoDescriptorCreator lives in org.apache.maven.lifecycle.internal, so this relies on internal Maven API that may move or change on Maven 4. Building the defaults Xpp3Dom from descriptor.getParameters() (name + getDefaultValue()/getExpression()) would avoid it.
---
_Generated by Claude Code_
Nit: constructing a throwaway RunMojo to read field initialiser defaults works, but the constructor also runs findJavaExecutable(toolchainManager, mavenSession) again. Not a problem today, just heavier than it looks; worth a comment, or a small factory that skips that lookup.
---
_Generated by Claude Code_
Looks good to me. This fixes a real problem: from an aggregator root, mn:run took the plugin configuration and the micronaut.test.resources.* properties from the root rather than from the selected application. Resetting the parameters before applying the application's configuration (the second commit) is the right call, and the unit tests plus the two ITs cover it well. Two non-blocking nits inline.
One cross-PR note: DevMojo in #1725 copies this "apply the selected application's configuration" logic but not the parameter reset, so it has the stale-root-value bug this PR fixes. It'd be worth extracting this into a shared helper both mojos use.
---
_Generated by Claude Code_
Done in a43a384d9: the default configuration is now built from MojoDescriptor.getMojoConfiguration() (each parameter's expression and default-value), as MojoDescriptorCreator.convert did, so RunMojo no longer imports anything from org.apache.maven.lifecycle.internal.
_🤖 Addressed by Claude Code_
Added a comment in a43a384d9 where the throwaway mojo is built: its constructor looks the Java executable up again through the toolchain, a small cost once per run that changes nothing in the reset.
_🤖 Addressed by Claude Code_
graemerocher
Related to micronaut-projects/micronaut-core#13654. This is the
mn:runcounterpart of the reactor fix that #1730 makes formn:devandmn:test. It is independent of that stack (#1725 → #1726 → #1730), so it targets5.1.xdirectly.The problem
mn:runis an aggregator. Run from a reactor root that does not declare the plugin, it selects the one module that does, the application. Maven configures a mojo from the project the goal was invoked on, though. So every property-backed parameter was evaluated against the root, and the application's own plugin configuration was ignored:micronaut.test.resources.enableditself ran without a Test Resources service. A root that enables it while the application disables it still started one.micronaut.test.resources.shared,.namespace,.versionand the other properties, and for<testResourcesDependencies>and<classpathInference>in the application'smicronaut-maven-pluginconfiguration.buildDirectorywas the root'starget. The service settings were written beside the root, while the launch read them from beside the application.The fix
When
mn:runselects the application from the reactor,RunMojoreconfigures itself as Maven would have configured it with-pl app:1. It resets the goal's editable parameters to a new mojo's values, because Maven's configurator does not assign an expression that resolves to nothing. Otherwise a value resolved only in the root would remain.
2. It takes the application's plugin-level configuration and merges the
default-cliexecution's configuration over it. It keeps only this goal's parameters and merges the result over the goal's own defaults and property expressions (MojoDescriptorCreator.convert).3. It applies the result with Maven's
basicconfigurator. APluginParameterExpressionEvaluatorevaluates it against the application, so command-line-Dproperties still win.When the goal runs on the application itself (a single-module project, or
-pl app), nothing changes.Tests
RunMojoReactorConfigurationTestcovers four cases: the application enables Test Resources and the root does not; the root enables it and the application disables it; a-Don the command line still wins; a value resolved only in the root does not remain. It also checks thatdefault-climerges over the plugin configuration and that other goals' settings are left out.test-resources-run-reactorhas a root without Test Resources, aresolvermodule (a customTestResourcesResolver, so no Docker is needed) and anappmodule. Theappmodule enables Test Resources in its own properties and adds the resolver through its own<testResourcesDependencies>. Runningmn:runfrom the root starts the service inapp/target, and the application prints the property the service resolves. The service is stopped afterwards.test-resources-run-reactor-disabledis the reverse: the root enables Test Resources and the application disables it. No service is started.multi-project,multi-project-multi-runnable,multi-project-multi-runnable-error,runandrun-aotstill pass.test-resources-runneeds Docker, so it was not run locally.