This story is a follow-up on Bug 471943 - Make Buildship work behind the firewall. The goal is to forward Eclipse's proxy settings to Gradle upon all interactions, including the model retrievals and the task executions.
Eclipse offers a simple API to query the current proxy settings.
IProxyService service = ... // get the service
for (IProxyData proxyData : service.getProxyData()) {
String type = proxyData.getType(); // can be IProxyData.HTTP_PROXY_TYPE for instance
String host = proxyData.getHost();
int port = proxyData.getPort();
String[] nonProxiedHosts = service.getNonProxiedHosts();
boolean authenticationRequired = proxyData.isRequiresAuthentication();
String user = proxyData.getUserId();
String pass = proxyData.getPassword();
}
Gradle has two phase we should consider: 1) time when accessing the tooling API and 2) after the IPC connection is established. The first case is where we specify proxies for the distribution download. The second is where we query models and execute tasks via the TAPI.
Gradle defines hard-coded places where it loads the proxy settings from (in ascending priority):
~/.gradle/gradle.properties
file- The
gradle.properties
file under the project root - In the system properties If we get the proxy settings from these locations, we can configure Buildship before accessing the tooling API.
Buildship should set the proxy setting if anything defined in the Eclipse preferences and ignore the settings from Gradle.
- Collect preferences from Eclipse
- Set the proxy setting as system properties before a
ToolingApiJob
orToolingApiWorkspaceJob
instance is scheduled and the revert them when finished - Specify the proxy settings as default JVM arguments for all
ToolingApiJob
andToolingApiWorkspaceJob
instances
- Simple tests for collecting preferences
- Test if the system properties are temporary changed when the jobs are running
- Test if the JVM arguments are automatically set when proxy settings are available
- Verify that subsequent build can have different proxy settings (~the daemon could cache the settings by reading the system properties only at startup)
- Test if the proxies are accessed upon task execution
- Copy over the
TestProxyServer
test fixture from Gradle core to do the integration testing
- Copy over the