[ 
https://issues.apache.org/jira/browse/MNG-8165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17864412#comment-17864412
 ] 

ASF GitHub Bot commented on MNG-8165:
-------------------------------------

gnodet commented on code in PR #1604:
URL: https://github.com/apache/maven/pull/1604#discussion_r1671290086


##########
maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java:
##########
@@ -320,12 +320,14 @@ void initialize(CliRequest cliRequest) throws 
ExitException {
         // We need to locate the top level project which may be pointed at 
using
         // the -f/--file option.  However, the command line isn't parsed yet, 
so
         // we need to iterate through the args to find it and act upon it.
-        Path topDirectory = Paths.get(cliRequest.workingDirectory);
+        Path cwd = Paths.get(cliRequest.workingDirectory);
+        // MavenCliTest extensively uses MULTIMODULE_PROJECT_DIRECTORY
+        Path topDirectory = cliRequest.multiModuleProjectDirectory.toPath();

Review Comment:
   In all cases, this PR is wrong.  `mavenMultiModuleDirectory` is similar to 
`session.rootDirectory`, but certainly not to `topDirectory`. 
   Just try the following:
   ```
   > mvn help:evaluate -Dexpression=session.topDirectory -N -f maven-core -q 
-DforceStdout
   <path>/Users/gnodet/work/git/maven/maven-core</path>%
   > mvn help:evaluate -Dexpression=maven.multiModuleProjectDirectory -N -f 
maven-core -q -DforceStdout
   /Users/gnodet/work/git/maven%                                                
                                                                                
                            ```





> Maven does not find extensions for -f when current dir is root
> --------------------------------------------------------------
>
>                 Key: MNG-8165
>                 URL: https://issues.apache.org/jira/browse/MNG-8165
>             Project: Maven
>          Issue Type: Bug
>    Affects Versions: 3.9.8
>            Reporter: Charles Oliver Nutter
>            Assignee: Tamas Cservenak
>            Priority: Major
>             Fix For: 3.9.9
>
>
> There seems to be a problem with how Maven locates the `.mvn/extensions.xml` 
> file if you run it at root. This appears to be breaking JRuby's user of 
> Polyglot Maven when running in a Docker container 
> (https://github.com/jruby/jruby/issues/7059)
> To reproduce (see long output at 
> https://github.com/jruby/jruby/issues/7059#issuecomment-2190953877):
>  # Be at the root of the filesystem
>  # Create `.mvn/extensions.xml` file that enables Polyglot Ruby
>  # Create a file `blah/pom.rb` containing a `#` that will be rejected as 
> invalid pom XML.
>  # Execute the file with `mvn -f blah/pom.rb clean`
> The expected behavior should be that it fills in a dummy group and artifact 
> ID for the blank ruby pom file and executes it correctly.
> Instead, it does not load Polyglot Ruby and attempts to parse the file as XML.
> I suspect that work done in [https://github.com/apache/maven/pull/94] for 
> MNG-5889 may have introduced this bug. Prior to that issue, Maven would 
> always look in the current directory for `.mvn` (which is root in this case), 
> which would allow this scenario to work. The fix was to have Maven look first 
> in the target directory and then in parent directories, but now it never 
> looks at root (`/.mvn`).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to