Class MavenProxySupport

java.lang.Object
org.netbeans.modules.maven.execute.MavenProxySupport

public class MavenProxySupport extends Object
Checks the proxy settings and possibly reconfigures Maven settings. The class checks the effective proxy settings using ProxySelector API, then reads the current Maven settings using EmbedderFactory.getProjectEmbedder(). If the maven settings do not contain proper proxy setup, maven options (MavenSettings.getNetworkProxy() is consulted:
  • IGNORE - no special handling
  • NOTICE - a notice is printed into the notifications area informing about possible bad proxy setup, no other action taken
  • UPDATE - maven configuration will be automatically updated (see below)
  • OVERRIDE - persistent global configuration is not changed, but a new settings file will be generated in $nbuser/var/cache/maven and maven BeanRunConfig will be instructed to use it
  • ASK - asks the user
If maven settings are updated, the original contents is preserved as settings.xml.old or a numbered settings.xml.old.N, first unused N is selected. If the settings file contins the proxy in effect, but not active, the active property of that proxy will be set to true, and the others to false. Otherwise a new proxy entry with the desired proxy host/port is created. To disable proxies, all active entries are set to false.

The MavenProxySupport.ProxyResult.configure(org.netbeans.modules.maven.execute.BeanRunConfig) should be run before each maven online invocation to potentially replace the global settings file with a customized one, that specifies the correct proxy.

When creating customized settings.xml files, the files are named like settings-[hashcode of the oroginal]-[sanitized proxy host].xml. If the settings.xml file does not exist at all, "new" is used instead of the hashcode. Proxy host sanitization just replaces weird characters by "_".