Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate the Maven settings argument when testing codestart-generated projects #21673

Merged
merged 1 commit into from
Nov 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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<String> command) {
if (System.getProperties().containsKey(name)) {
final StringBuilder buf = new StringBuilder();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are so use to use StringBuffer that you call it buf 😂

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);
Expand Down