mvnd native executable is not passing -Dkey=val to the daemon #157

This commit is contained in:
Peter Palaga
2020-10-27 01:24:07 +01:00
parent 6e46188586
commit 59a9bbad5b
4 changed files with 22 additions and 10 deletions

View File

@@ -122,6 +122,7 @@
-H:IncludeResources=org/jboss/fuse/mvnd/.* -H:IncludeResources=org/jboss/fuse/mvnd/.*
-H:IncludeResources=org/jline/utils/.* -H:IncludeResources=org/jline/utils/.*
-H:IncludeResources=org/fusesource/jansi/jansi.properties -H:IncludeResources=org/fusesource/jansi/jansi.properties
-H:-ParseRuntimeOptions
</buildArgs> </buildArgs>
</configuration> </configuration>
</plugin> </plugin>

View File

@@ -88,7 +88,6 @@ public class DefaultClient implements Client {
boolean version = false; boolean version = false;
boolean showVersion = false; boolean showVersion = false;
boolean debug = false; boolean debug = false;
final Properties commandLineProperties = new Properties();
for (String arg : argv) { for (String arg : argv) {
switch (arg) { switch (arg) {
case "-v": case "-v":
@@ -111,9 +110,9 @@ public class DefaultClient implements Client {
if (arg.startsWith("-D")) { if (arg.startsWith("-D")) {
final int eqPos = arg.indexOf('='); final int eqPos = arg.indexOf('=');
if (eqPos >= 0) { if (eqPos >= 0) {
commandLineProperties.setProperty(arg.substring(2, eqPos), arg.substring(eqPos + 1)); System.setProperty(arg.substring(2, eqPos), arg.substring(eqPos + 1));
} else { } else {
commandLineProperties.setProperty(arg.substring(2), ""); System.setProperty(arg.substring(2), "");
} }
} }
args.add(arg); args.add(arg);

View File

@@ -42,11 +42,14 @@ public class ModuleAndPluginNativeIT {
@Test @Test
void cleanInstall() throws IOException, InterruptedException { void cleanInstall() throws IOException, InterruptedException {
final Path helloPath = layout.multiModuleProjectDirectory().resolve("hello/target/hello.txt"); final Path helloPath = layout.multiModuleProjectDirectory().resolve("hello/target/hello.txt");
try { final Path helloPropertyPath = layout.multiModuleProjectDirectory().resolve("hello/target/hello.property.txt");
Files.deleteIfExists(helloPath); Stream.of(helloPath, helloPropertyPath).forEach(p -> {
} catch (IOException e) { try {
throw new RuntimeException("Could not delete " + helloPath); Files.deleteIfExists(p);
} } catch (IOException e) {
throw new RuntimeException("Could not delete " + p);
}
});
final Path localMavenRepo = layout.getLocalMavenRepository(); final Path localMavenRepo = layout.getLocalMavenRepository();
TestUtils.deleteDir(localMavenRepo); TestUtils.deleteDir(localMavenRepo);
@@ -59,10 +62,13 @@ public class ModuleAndPluginNativeIT {
/* Build #1: with "Hello" output to target/hello.txt */ /* Build #1: with "Hello" output to target/hello.txt */
{ {
final ClientOutput output = Mockito.mock(ClientOutput.class); final ClientOutput output = Mockito.mock(ClientOutput.class);
client.execute(output, "clean", "install", "-e", "-Dmvnd.log.level=DEBUG").assertSuccess(); client.execute(output, "clean", "install", "-e", "-Dmvnd.log.level=DEBUG", "-Dhello.property=Hello1")
.assertSuccess();
Assertions.assertThat(helloPath).exists(); Assertions.assertThat(helloPath).exists();
Assertions.assertThat(helloPath).usingCharset(StandardCharsets.UTF_8).hasContent("Hello"); Assertions.assertThat(helloPath).usingCharset(StandardCharsets.UTF_8).hasContent("Hello");
Assertions.assertThat(helloPropertyPath).exists();
Assertions.assertThat(helloPropertyPath).usingCharset(StandardCharsets.UTF_8).hasContent("Hello1");
Stream.of(installedJars).forEach(jar -> Assertions.assertThat(jar).exists()); Stream.of(installedJars).forEach(jar -> Assertions.assertThat(jar).exists());
} }
@@ -75,10 +81,12 @@ public class ModuleAndPluginNativeIT {
final ClientOutput output = Mockito.mock(ClientOutput.class); final ClientOutput output = Mockito.mock(ClientOutput.class);
client.execute(output, client.execute(output,
"clean", "clean",
"install", "-e", "-Dmvnd.log.level=DEBUG").assertSuccess(); "install", "-e", "-Dmvnd.log.level=DEBUG", "-Dhello.property=Hello2").assertSuccess();
Assertions.assertThat(helloPath).exists(); Assertions.assertThat(helloPath).exists();
Assertions.assertThat(helloPath).usingCharset(StandardCharsets.UTF_8).hasContent("Hi"); Assertions.assertThat(helloPath).usingCharset(StandardCharsets.UTF_8).hasContent("Hi");
Assertions.assertThat(helloPropertyPath).exists();
Assertions.assertThat(helloPropertyPath).usingCharset(StandardCharsets.UTF_8).hasContent("Hello2");
Stream.of(installedJars).forEach(jar -> Assertions.assertThat(jar).exists()); Stream.of(installedJars).forEach(jar -> Assertions.assertThat(jar).exists());
} }

View File

@@ -35,6 +35,9 @@ public class HelloMojo extends AbstractMojo {
@Parameter @Parameter
File file; File file;
@Parameter(property = "hello.property", defaultValue = "Hello")
String property;
@Override @Override
public void execute() throws MojoExecutionException, MojoFailureException { public void execute() throws MojoExecutionException, MojoFailureException {
@@ -42,6 +45,7 @@ public class HelloMojo extends AbstractMojo {
final Path path = file.toPath(); final Path path = file.toPath();
Files.createDirectories(path.getParent()); Files.createDirectories(path.getParent());
Files.write(path, "Hello".getBytes(StandardCharsets.UTF_8)); Files.write(path, "Hello".getBytes(StandardCharsets.UTF_8));
Files.write(path.getParent().resolve("hello.property.txt"), property.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("", e); throw new RuntimeException("", e);
} }