desruisseaux commented on code in PR #11394:
URL: https://github.com/apache/maven/pull/11394#discussion_r2499401868
##########
impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultSourceRoot.java:
##########
@@ -169,7 +169,7 @@ public DefaultSourceRoot(final Path baseDir, ProjectScope
scope, Resource resour
resource.getIncludes(),
resource.getExcludes(),
Boolean.parseBoolean(resource.getFiltering()),
-
nonBlank(resource.getTargetPath()).map(baseDir::resolve).orElse(null),
+ nonBlank(resource.getTargetPath()).map(Path::of).orElse(null),
Review Comment:
`Path.of(String)` creates a path relative the to current working directory,
which is not the desired output directory. I think that `DefaultSourceRoot` is
okay, and the change rather needs to be applied in the codes that call this
constructor. The problem seems to be in the following classes:
* `org.apache.maven.project.ConnectedResource` line 124.
* `org.apache.maven.project.DefaultProjectBuilder` lines 704 and 707.
* `org.apache.maven.project.MavenProject` line 840
The above-cited codes set the first parameter to
`project.getBaseDirectory()` while it should be
`project.getBuild().getOutputDirectory()`.
Note: the `baseDir` parameter name of `DefaultSourceRoot` is misleading. The
Javadoc said _"the base directory for resolving relative paths"_, which can be
the `baseDir` of the Maven project but not necessarily. It should be understood
as any base directory for resolving paths. This parameter could be renamed
`parentDir` if `baseDir` is too misleading.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]