-
Notifications
You must be signed in to change notification settings - Fork 866
/
YarnRunner.java
54 lines (40 loc) · 1.77 KB
/
YarnRunner.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.github.eirslett.maven.plugins.frontend.lib;
import java.util.ArrayList;
import java.util.List;
import com.github.eirslett.maven.plugins.frontend.lib.ProxyConfig.Proxy;
public interface YarnRunner extends NodeTaskRunner {
}
final class DefaultYarnRunner extends YarnTaskExecutor implements YarnRunner {
private static final String TASK_NAME = "yarn";
public DefaultYarnRunner(YarnExecutorConfig config, ProxyConfig proxyConfig, String npmRegistryURL) {
super(config, TASK_NAME, config.getYarnPath().getAbsolutePath(),
buildArguments(config, proxyConfig, npmRegistryURL));
}
private static List<String> buildArguments(final YarnExecutorConfig config, ProxyConfig proxyConfig,
String npmRegistryURL) {
List<String> arguments = new ArrayList<>();
if (config.isYarnBerry()) {
// Yarn berry does not support the additional arguments we try to set below.
// Setting those results in failures during yarn execution.
return arguments;
}
if (npmRegistryURL != null && !npmRegistryURL.isEmpty()) {
arguments.add("--registry=" + npmRegistryURL);
}
if (!proxyConfig.isEmpty()) {
Proxy proxy = null;
if (npmRegistryURL != null && !npmRegistryURL.isEmpty()) {
proxy = proxyConfig.getProxyForUrl(npmRegistryURL);
}
if (proxy == null) {
proxy = proxyConfig.getSecureProxy();
}
if (proxy == null) {
proxy = proxyConfig.getInsecureProxy();
}
arguments.add("--https-proxy=" + proxy.getUri().toString());
arguments.add("--proxy=" + proxy.getUri().toString());
}
return arguments;
}
}