Proxy Setup for Graal Cloud Native Tools in VS Code

This guide suggests how to configure proxy settings for Maven, Gradle, and Kubernetes which are the prerequisites to successfully use the Graal Cloud Native and OCI DevOps Tools in VS Code.

VS Code reads the operating system proxy settings on Windows and macOS, unlike Linux. Often, extensions do not go as deep as OS integration and rely on the environment variables. VS Code allows for an explicit proxy URL in the global configuration, but that must be read explicitly by the extension(s). If the configuration is not done, the build system launched to prime the project, download artifacts, or serve information to the extension may produce no or damaged data on a VPN. Note the extensions are independent of each other.


It is not recommended to change your network during a VS Code session. If you do, observe the following recommendations:

  1. Stop a VS Code session.
  2. Kill all Gradle/Maven Daemon processes that may still be running.
  3. Configure a proxy in the Gradle settings if you use Gradle for your project (see Configure Proxy Support for Gradle).
  4. Configure a proxy in the Maven settings if you use Maven for your project (see Configure Proxy Support for Maven).
  5. Start VS Code again.

Note: When you switch to an open (non-proxy) network, you must reconfigure the settings before running VS Code.

The user experience may vary depending on the operating system, the state of the project (if a user executed a build and the Gradle wrapper downloaded the Gradle distribution), and the order of extensions activation. For example, Apache NetBeans Language Server may be able to fetch the Gradle distribution before Microsoft Java attempts to use it.

Configure Proxy Support for Gradle #

Gradle requires a proxy to be configured in the machine-wire ~/.gradle/gradle.properties file or the project root’s gradle.properties (not recommended, as the file is shared).

  1. Open the Gradle global settings, _%USERPROFILE%/.gradle/gradle.properties__, and add the proxy configuration:

     systemProp.http.proxyHost=your.proxy.address
     systemProp.http.proxyPort=80
    
  2. Set http.proxy (or https.proxy if required) in the VS Code global settings:

    • In VS Code, click the gear icon in the bottom left corner, and go to Settings. Or go to Code, then Preferences, and click Settings.
    • Open Settings JSON file by clicking an arrow-paper icon in the top right:

      Open VS Code Settings JSON

    • Add the following code:
      {
      "http.proxy": "http://user:pass@your.proxy.address:8080",
      "http.proxyStrictSSL": false,
      }
      
  3. Restart VS Code.

Alternatively, you can edit VS Code settings.json outside the UI. The location of the file differs per OS:

  • Windows: %APPDATA%\Code\User\settings.json
  • macOS: $HOME/Library/Application Support/Code/User/settings.json
  • Linux: $HOME/.config/Code/User/settings.json

Configure Proxy Support for Maven #

If you use Maven for your project, you need to configure proxy support for Maven. Maven also requires a proxy to be configured in the machine-wire ~/.m2/settings.xml file. The Maven launcher is simpler than Gradle (Maven daemon comes in later versions).

  1. Open the Maven global settings, %USERPROFILE%/.m2/settings.xml, and add the proxy configuration into the <settings> block:
     <settings>
       <proxies>
         <proxy>
           <id>your.proxy.id</id>
           <active>true</active>
           <protocol>https</protocol>
           <host>your.proxy.address</host>
           <port>80</port>
         </proxy>
       </proxies>
     </settings>
    

    Where %USERPROFILE% is your user directory.

  2. Set http.proxy (or HTTPS if required) in the VS Code global settings:
    • In VS Code, click the gear icon in the bottom left corner, and go to Settings. Or go to Code, then Preferences, and click Settings.
    • Open Settings JSON file by clicking an arrow-paper icon in the top right:

      Open VS Code Settings JSON

    • Add the following code:
      {
      "http.proxy": "http://user:pass@your.proxy.address:8080",
      "http.proxyStrictSSL": false,
      }
      
  3. Restart VS Code.

Configure Proxy Support for Kubernetes #

On Windows, kubectl is typically installed within the Kubernetes extension and is not added to the system path. Windows users should configure a proxy in the configuration file, .kube/config. Add a proxy-url property under cluster:

clusters:
- name: "dev"
  cluster:
    proxy-url: http://user:password@proxy:port
    ...