Search code examples
eclipseproxyeclipse-rcpequinoxheadless-rcp

How to set the proxy configuration for a headless Eclipse application on Windows


I have a script which needs to call one of the existing, headless Eclipse applications (example: the p2 director application) which use the Proxy API of org.eclipse.core.net for configuring its requests to HTTP servers.

On Linux, I can configure the Eclipse Proxy API by setting the environment variables http_proxy and https_proxy.

Is there similar solution for configuring the proxies from the command line in Windows?


I've tried to set HTTP proxy configuration properties specified by Java (http.proxyHost, http.proxyPort, etc.) but this doesn't work. Setting the properties just results in a log entry from Eclipse informing me that the system properties are overwritten with the values from the preferences:

!ENTRY org.eclipse.core.net 1 0 2013-08-09 15:21:19.413
!MESSAGE System property http.proxyHost has been set to proxy by an external source. This value will be overwritten using the values from the preferences

!ENTRY org.eclipse.core.net 1 0 2013-08-09 15:21:19.414
!MESSAGE System property http.proxyPort has been set to 8080 by an external source. This value will be overwritten using the values from the preferences

So another option would be a headless application which allows to configure preferences. Does this application exist (preferrably as part of the standard Eclipse distributions)?


Solution

  • Proxy preferences for Eclipse applications are stored in the file

    <eclipse-installation>/configuration/.settings/org.eclipse.core.net.prefs
    

    So either you edit the settings via the Eclipse preferences UI (General / Network Connections) and then copy that file to your headless application, or you create/edit that manually:

    eclipse.preferences.version=1
    nonProxiedHosts=localhost|127.0.0.1
    org.eclipse.core.net.hasMigrated=true
    proxiesEnabled=true
    proxyData/HTTP/hasAuth=false
    proxyData/HTTP/host=<proxy.your.org>
    proxyData/HTTP/port=<port>
    proxyData/HTTPS/hasAuth=false
    proxyData/HTTPS/host=<proxy.your.org>
    proxyData/HTTPS/port=<port>
    # - Set SOCKS proxy only if neccessary -
    # proxyData/SOCKS/hasAuth=false
    # proxyData/SOCKS/host=<proxy.your.org>
    # proxyData/SOCKS/port=<port>
    systemProxiesEnabled=false
    

    HTH.