diff --git a/independent-projects/tools/devtools-testing/src/main/java/io/quarkus/devtools/testing/WrapperRunner.java b/independent-projects/tools/devtools-testing/src/main/java/io/quarkus/devtools/testing/WrapperRunner.java index 190b4e6700c64..fb5f16eb025df 100644 --- a/independent-projects/tools/devtools-testing/src/main/java/io/quarkus/devtools/testing/WrapperRunner.java +++ b/independent-projects/tools/devtools-testing/src/main/java/io/quarkus/devtools/testing/WrapperRunner.java @@ -1,5 +1,6 @@ package io.quarkus.devtools.testing; +import io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -71,8 +72,14 @@ public static int run(Path projectDir, Wrapper wrapper) { command.add(projectDir.resolve(wrapper.getExec()).toAbsolutePath().toString()); command.addAll(Arrays.asList(wrapper.getCmdArgs())); - if (System.getProperties().containsKey("maven.repo.local")) { - command.add("-Dmaven.repo.local=" + System.getProperty("maven.repo.local")); + propagateSystemPropertyIfSet("maven.repo.local", command); + + if (wrapper == Wrapper.MAVEN) { + final String mavenSettings = getMavenSettingsArg(); + if (mavenSettings != null) { + command.add("-s"); + command.add(mavenSettings); + } } try { @@ -95,6 +102,26 @@ public static int run(Path projectDir, Wrapper wrapper) { return -1; } + private static String getMavenSettingsArg() { + final String mavenSettings = System.getProperty("maven.settings"); + if (mavenSettings != null) { + return mavenSettings; + } + return BootstrapMavenOptions.newInstance().getOptionValue(BootstrapMavenOptions.ALTERNATE_USER_SETTINGS); + } + + private static void propagateSystemPropertyIfSet(String name, List command) { + if (System.getProperties().containsKey(name)) { + final StringBuilder buf = new StringBuilder(); + buf.append("-D").append(name); + final String value = System.getProperty(name); + if (value != null && !value.isEmpty()) { + buf.append("=").append(value); + } + command.add(buf.toString()); + } + } + private static void streamToSysOutSysErr(final Process process) { streamOutputToSysOut(process); streamErrorToSysErr(process);