Skip to content

Commit

Permalink
Read Proxy settings from ~/.m2/versioneye.properties
Browse files Browse the repository at this point in the history
  • Loading branch information
reiz committed Feb 29, 2016
1 parent 8bd15e3 commit 67f0970
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/main/java/com/versioneye/SuperMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,42 @@ public void checkServerTrusted(X509Certificate[] certs, String authType){}
}

protected void setProxy(){
try{
if (proxyHost == null || proxyHost.isEmpty()){
String propertiesPath = homeDirectory + "/.m2/" + propertiesFile;
String host = getPropertyFromPath(propertiesPath, "proxyHost");
if (host != null && !host.isEmpty()){
proxyHost = host;
}
}

if (proxyPort == null || proxyPort.isEmpty() ){
propertiesPath = homeDirectory + "/.m2/" + propertiesFile;
String port = getPropertyFromPath(propertiesPath, "proxyPort");
if (port != null && !port.isEmpty()){
proxyPort = port;
}
}

if (proxyUser == null || proxyUser.isEmpty()){
propertiesPath = homeDirectory + "/.m2/" + propertiesFile;
String user = getPropertyFromPath(propertiesPath, "proxyUser");
if (user != null && !user.isEmpty()){
proxyUser = user;
}
}

if (proxyPassword == null || proxyPassword.isEmpty()){
propertiesPath = homeDirectory + "/.m2/" + propertiesFile;
String password = getPropertyFromPath(propertiesPath, "proxyPassword");
if (password != null && !password.isEmpty()){
proxyPassword = password;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}

boolean emptyProxyHost = proxyHost == null || proxyHost.isEmpty();
boolean emptyProxyPort = proxyPort == null || proxyPort.isEmpty();
if (emptyProxyHost && emptyProxyPort){
Expand Down

0 comments on commit 67f0970

Please sign in to comment.