mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-13 14:39:29 +00:00
@@ -31,6 +31,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import org.fusesource.jansi.Ansi;
|
import org.fusesource.jansi.Ansi;
|
||||||
import org.fusesource.jansi.internal.CLibrary;
|
import org.fusesource.jansi.internal.CLibrary;
|
||||||
@@ -235,22 +236,19 @@ public class DefaultClient implements Client {
|
|||||||
return DefaultResult.success(argv);
|
return DefaultResult.success(argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment.MVND_THREADS.removeCommandLineOption(args);
|
Optional<String> threads = Optional.ofNullable(Environment.MVND_THREADS.removeCommandLineOption(args));
|
||||||
Environment.MVND_THREADS.addCommandLineOption(args, parameters.threads());
|
Environment.MVND_THREADS.addCommandLineOption(args, threads.orElseGet(parameters::threads));
|
||||||
|
|
||||||
Environment.MVND_BUILDER.removeCommandLineOption(args);
|
Optional<String> builder = Optional.ofNullable(Environment.MVND_BUILDER.removeCommandLineOption(args));
|
||||||
Environment.MVND_BUILDER.addCommandLineOption(args, parameters.builder());
|
Environment.MVND_BUILDER.addCommandLineOption(args, builder.orElseGet(parameters::builder));
|
||||||
|
|
||||||
final Path settings = parameters.settings();
|
Optional<String> settings = Optional.ofNullable(Environment.MAVEN_SETTINGS.removeCommandLineOption(args))
|
||||||
if (settings != null) {
|
.or(() -> Optional.ofNullable(parameters.settings()).map(Path::toString));
|
||||||
Environment.MAVEN_SETTINGS.removeCommandLineOption(args);
|
settings.ifPresent(s -> Environment.MAVEN_SETTINGS.addCommandLineOption(args, s));
|
||||||
Environment.MAVEN_SETTINGS.addCommandLineOption(args, settings.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
final Path localMavenRepository = parameters.mavenRepoLocal();
|
Optional<String> repo = Optional.ofNullable(Environment.MAVEN_REPO_LOCAL.removeCommandLineOption(args))
|
||||||
if (localMavenRepository != null && !Environment.MAVEN_REPO_LOCAL.hasCommandLineOption(args)) {
|
.or(() -> Optional.ofNullable(parameters.mavenRepoLocal()).map(Path::toString));
|
||||||
Environment.MAVEN_REPO_LOCAL.addCommandLineOption(args, localMavenRepository.toString());
|
repo.ifPresent(r -> Environment.MAVEN_REPO_LOCAL.addCommandLineOption(args, r));
|
||||||
}
|
|
||||||
|
|
||||||
Environment.MVND_TERMINAL_WIDTH.addCommandLineOption(args, Integer.toString(output.getTerminalWidth()));
|
Environment.MVND_TERMINAL_WIDTH.addCommandLineOption(args, Integer.toString(output.getTerminalWidth()));
|
||||||
|
|
||||||
|
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2021 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mvndaemon.mvnd.it;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mvndaemon.mvnd.assertj.TestClientOutput;
|
||||||
|
import org.mvndaemon.mvnd.client.Client;
|
||||||
|
import org.mvndaemon.mvnd.client.DaemonParameters;
|
||||||
|
import org.mvndaemon.mvnd.junit.MvndNativeTest;
|
||||||
|
|
||||||
|
@MvndNativeTest(projectDir = "src/test/projects/multi-module")
|
||||||
|
public class ThreadOptionNativeIT {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Client client;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
DaemonParameters parameters;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void minusTSpace2() throws IOException, InterruptedException {
|
||||||
|
final TestClientOutput output = new TestClientOutput();
|
||||||
|
|
||||||
|
client.execute(output, "-T", "2", "verify").assertSuccess();
|
||||||
|
|
||||||
|
output.assertContainsMatchingSubsequence("Using the SmartBuilder implementation with a thread count of 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void minusT2() throws IOException, InterruptedException {
|
||||||
|
final TestClientOutput output = new TestClientOutput();
|
||||||
|
|
||||||
|
client.execute(output, "-T2", "verify").assertSuccess();
|
||||||
|
|
||||||
|
output.assertContainsMatchingSubsequence("Using the SmartBuilder implementation with a thread count of 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void minusThreadsSpace2() throws IOException, InterruptedException {
|
||||||
|
final TestClientOutput output = new TestClientOutput();
|
||||||
|
|
||||||
|
client.execute(output, "--threads", "2", "verify").assertSuccess();
|
||||||
|
|
||||||
|
output.assertContainsMatchingSubsequence("Using the SmartBuilder implementation with a thread count of 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void minusThreads2() throws IOException, InterruptedException {
|
||||||
|
final TestClientOutput output = new TestClientOutput();
|
||||||
|
|
||||||
|
client.execute(output, "--threads=2", "verify").assertSuccess();
|
||||||
|
|
||||||
|
output.assertContainsMatchingSubsequence("Using the SmartBuilder implementation with a thread count of 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void mvndThreads() throws IOException, InterruptedException {
|
||||||
|
final TestClientOutput output = new TestClientOutput();
|
||||||
|
|
||||||
|
client.execute(output, "-Dmvnd.threads=2", "verify").assertSuccess();
|
||||||
|
|
||||||
|
output.assertContainsMatchingSubsequence("Using the SmartBuilder implementation with a thread count of 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isNative() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2021 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.mvndaemon.mvnd.it;
|
||||||
|
|
||||||
|
import org.mvndaemon.mvnd.junit.MvndTest;
|
||||||
|
|
||||||
|
@MvndTest(projectDir = "src/test/projects/multi-module")
|
||||||
|
public class ThreadOptionTest extends ThreadOptionNativeIT {
|
||||||
|
|
||||||
|
protected boolean isNative() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user