Skip to content
Permalink
Browse files

34: Simplify Gradle proxy plugin

Reviewed-by: rwestberg
  • Loading branch information
Erik Helin
Erik Helin committed Jul 1, 2019
1 parent 2a1e24b commit 0226b40f4937fc7f22d5fc884429b37e62aeb935
Showing with 8 additions and 8 deletions.
  1. +8 −8 buildSrc/proxy/src/main/java/org/openjdk/skara/gradle/proxy/ProxyPlugin.java
@@ -26,8 +26,10 @@
import org.gradle.api.Plugin;
import org.gradle.api.Project;

import java.net.*;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class ProxyPlugin implements Plugin<Project> {
public void apply(Project project) {
@@ -45,13 +47,11 @@ public void apply(Project project) {
}
var no_proxy = System.getenv("no_proxy");
no_proxy = no_proxy == null ? System.getenv("NO_PROXY") : no_proxy;
if (no_proxy != null) {
var hosts = no_proxy.replace(",", "|")
.replaceAll("^\\.", "*.")
.replaceAll("\\|\\.", "|*.");
if (System.getProperty("http.nonProxyHosts") == null) {
System.setProperty("http.nonProxyHosts", hosts);
}
if (no_proxy != null && System.getProperty("http.nonProxyHosts") == null) {
var hosts = Arrays.stream(no_proxy.split(","))
.map(s -> s.startsWith(".") ? "*" + s : s)
.collect(Collectors.toList());
System.setProperty("http.nonProxyHosts", String.join("|", hosts));
}
}
}

0 comments on commit 0226b40

Please sign in to comment.
You can’t perform that action at this time.