michael-o commented on code in PR #1061:
URL: https://github.com/apache/maven/pull/1061#discussion_r1152000103
##########
maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java:
##########
@@ -494,14 +504,50 @@ public interface MavenExecutionRequest {
/**
* @since 3.3.0
+ * @deprecated use {@link #setRootdir(Path)} instead
*/
+ @Deprecated
void setMultiModuleProjectDirectory(File file);
/**
* @since 3.3.0
+ * @deprecated use {@link #getRootdir()} instead
*/
+ @Deprecated
File getMultiModuleProjectDirectory();
+ /**
+ * Sets the root dir of the project.
+ *
+ * @since 4.0.0
+ */
+ MavenExecutionRequest setRootdir(Path rootdir);
+
+ /**
+ * Gets the root directory of the project, which is the parent directory
containing the {@code .mvn} directory.
+ * If there's no such file, an {@code IllegalArgumentException} will be
thrown.
+ *
+ * @throws IllegalArgumentException if the root directory could not be
found
Review Comment:
Isn't this `IllegalStateException`?
##########
maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java:
##########
@@ -133,6 +134,21 @@ public Object getValue(String expression) {
valueSources.add(new
BuildTimestampValueSource(config.getBuildStartTime(), modelProperties));
}
+ valueSources.add(new AbstractValueSource(false) {
+ @Override
+ public Object getValue(String expression) {
+ if ("rootdir".equals(expression)) {
+ Path path = config.getRootdir();
+ if (path != null) {
+ return path.toString();
+ }
+ throw new IllegalArgumentException("Unable to find the
root directory. "
Review Comment:
ISE rather? The expression isn't invalid but the state within, no?
##########
maven-model-builder/src/main/java/org/apache/maven/model/path/ProfileActivationFilePathInterpolator.java:
##########
@@ -79,6 +80,25 @@ public Object getValue(String expression) {
return null;
}
+ interpolator.addValueSource(new AbstractValueSource(false) {
+ @Override
+ public Object getValue(String expression) {
+ /*
+ * We intentionally only support ${rootdir} and not
${session.rootdir} as the latter form
+ * would suggest that other session.* expressions can be used
which is beyond the design.
+ */
+ if ("rootdir".equals(expression)) {
+ Path path = context.getRootdir();
+ if (path != null) {
+ return path.toString();
+ }
+ throw new IllegalArgumentException("Unable to find the
root directory. "
Review Comment:
Same here
##########
maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java:
##########
@@ -321,6 +323,46 @@ void initialize(CliRequest cliRequest) throws
ExitException {
}
}
+ Path topdir = Paths.get(cliRequest.workingDirectory);
+ boolean isAltFile = false;
+ for (String arg : cliRequest.args) {
+ if (isAltFile) {
+ Path path = Paths.get(arg);
+ if (Files.isDirectory(path)) {
Review Comment:
Granted.
--
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]