[ https://issues.apache.org/jira/browse/MNG-7038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17714148#comment-17714148 ]
ASF GitHub Bot commented on MNG-7038: ------------------------------------- gnodet commented on code in PR #1061: URL: https://github.com/apache/maven/pull/1061#discussion_r1171483867 ########## maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java: ########## @@ -320,6 +324,49 @@ void initialize(CliRequest cliRequest) throws ExitException { } } + Path topDirectory = Paths.get(cliRequest.workingDirectory); + boolean isAltFile = false; + for (String arg : cliRequest.args) { + if (isAltFile) { + Path path = Paths.get(arg); + if (Files.isDirectory(path)) { + topDirectory = path; + } else if (Files.isRegularFile(topDirectory)) { + topDirectory = path.getParent(); + if (!Files.isDirectory(topDirectory)) { + System.err.println("Directory " + topDirectory + + " extracted from the -f/--file command-line argument " + arg + " does not exist"); + throw new ExitException(1); + } + } else { + System.err.println( + "POM file " + arg + " specified with the -f/--file command line argument does not exist"); + throw new ExitException(1); + } + break; + } else { + isAltFile = arg.equals(String.valueOf(CLIManager.ALTERNATE_POM_FILE)) || arg.equals("file"); Review Comment: Well, the CLI isn't built yet, this is really one of the first things done. Also the point is to be able to leverage those properties during argument interpolation (see https://github.com/apache/maven/pull/1062), so this really has to be done very early. > Introduce public property to point to a root directory of (multi-module) > project > -------------------------------------------------------------------------------- > > Key: MNG-7038 > URL: https://issues.apache.org/jira/browse/MNG-7038 > Project: Maven > Issue Type: Improvement > Reporter: Envious Guest > Assignee: Guillaume Nodet > Priority: Major > Fix For: 4.0.0-alpha-6 > > > This is a request to expose a property *maven.multiModuleProjectDirectory* > which is currently internal (or introduce a brand new one with analogous > functionality). > * For a single-module project, its value should be same as *project.basedir* > * For multi-module project, its value should point to a project.basedir of a > root module > Example: > multi-module // located at /home/me/sources > +- module-a > +- module B > Sample multi-module/pom.xml: > {{<project>}} > {{ <parent>}} > {{ <groupId>com.acme</groupId>}} > {{ <artifactId>corp-parent</artifactId>}} > {{ <version>1.0.0-RELEASE</version>}} > {{ </parent>}} > {{ <groupId>com.acme</groupId>}} > {{ <artifactId>multi-module</artifactId>}} > {{ <version>0.5.2-SNAPSHOT</version>}} > {{ <modules>}} > {{ <module>module-a</module>}} > {{ <module>module-b</module>}} > {{ </modules>}} > {{</project>}} > The property requested should return /home/me/sources/multi-module, > regardless of whether it's referenced in any of the child modules (module-a, > module-b) or in multi-module. > Note that multi-module itself has parent (e.g. installed in a local > repository), so the new property should be smart enough to detect it and > still point to /home/me/sources/multi-module instead of the local repository > where the corp-parent is installed. > The use-case for such a property could be to have a directory for combined > report of static analysis tools. Typical example - jacoco combined coverage > reports. -- This message was sent by Atlassian Jira (v8.20.10#820010)