Skip to content

Commit

Permalink
Fix maven.multiModuleProjectDirectory (fixes #1031) (#1057)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet authored Jul 16, 2024
1 parent e8cb521 commit 9644e46
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ public static void main(String[] argv) throws Exception {
} else {
dir = parameters.userDir();
}
Path multiModuleProjectDirectory = parameters.multiModuleProjectDirectory(dir);
System.setProperty(
Environment.MAVEN_MULTIMODULE_PROJECT_DIRECTORY.getProperty(),
parameters.multiModuleProjectDirectory(dir).toString());
Environment.MAVEN_MULTIMODULE_PROJECT_DIRECTORY.getProperty(), multiModuleProjectDirectory.toString());
Environment.MAVEN_MULTIMODULE_PROJECT_DIRECTORY.addCommandLineOption(
args, multiModuleProjectDirectory.toString());

// .mvn/jvm.config
if (Files.isRegularFile(parameters.jvmConfigPath())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
@MvndNativeTest(projectDir = "src/test/projects/maven-conf-ignore-ext")
class MavenConfIgnoreExtNativeIT extends MavenConfNativeIT {
@Override
protected List<String> mvndParams() {
ArrayList<String> result = new ArrayList<>(super.mvndParams());
protected List<String> mvndParams(String expression) {
ArrayList<String> result = new ArrayList<>(super.mvndParams(expression));
result.add("-Dmvnd.coreExtensionsExclude=foo:bar");
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import javax.inject.Inject;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

Expand All @@ -42,7 +41,7 @@ class MavenConfNativeIT {
DaemonParameters parameters;

@Test
void version() throws IOException, InterruptedException {
void version() throws InterruptedException {
final TestClientOutput o = new TestClientOutput();
// this test also exercise the "-D foo=bar" syntax for defining properties
client.execute(o, mvndParams().toArray(new String[0])).assertSuccess();
Expand All @@ -51,11 +50,34 @@ void version() throws IOException, InterruptedException {
o.getMessages().stream().anyMatch(m -> m.toString().contains(conf)), "Output should contain " + conf);
}

@Test
void interpolation() throws InterruptedException {
final TestClientOutput o = new TestClientOutput();
client.execute(o, mvndParams("something").toArray(new String[0])).assertSuccess();
String conf = parameters.multiModuleProjectDirectory().toString();
assertTrue(
o.getMessages().stream().anyMatch(m -> m.toString().contains(conf)), "Output should contain " + conf);
}

@Test
void multiModuleProjectDirectory() throws InterruptedException {
final TestClientOutput o = new TestClientOutput();
client.execute(o, mvndParams("maven.multiModuleProjectDirectory").toArray(new String[0]))
.assertSuccess();
String conf = parameters.multiModuleProjectDirectory().toString();
assertTrue(
o.getMessages().stream().anyMatch(m -> m.toString().contains(conf)), "Output should contain " + conf);
}

protected List<String> mvndParams() {
return mvndParams("maven.conf");
}

protected List<String> mvndParams(String expression) {
return Arrays.asList(
"org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate",
"-D",
"expression=maven.conf",
"expression=" + expression,
"-q",
"-DforceStdout",
"--raw-streams",
Expand Down

0 comments on commit 9644e46

Please sign in to comment.