Repository: flex-utilities
Updated Branches:
  refs/heads/develop ac6873440 -> 5bd8a7987


Moved the proxy initialization code to a place that it's always initialized


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/5bd8a798
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/5bd8a798
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/5bd8a798

Branch: refs/heads/develop
Commit: 5bd8a7987bd218621964bad3824cc3e96f3c043f
Parents: ac68734
Author: Christofer Dutz <christofer.d...@codecentric.de>
Authored: Tue Oct 20 15:52:03 2015 +0200
Committer: Christofer Dutz <christofer.d...@codecentric.de>
Committed: Tue Oct 20 15:52:03 2015 +0200

----------------------------------------------------------------------
 .../converter/mavenextension/FlexEventSpy.java  | 57 ++++++++++----------
 1 file changed, 27 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/5bd8a798/flex-maven-tools/flex-sdk-converter/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
----------------------------------------------------------------------
diff --git 
a/flex-maven-tools/flex-sdk-converter/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
 
b/flex-maven-tools/flex-sdk-converter/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
index cda8011..2eaea81 100644
--- 
a/flex-maven-tools/flex-sdk-converter/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
+++ 
b/flex-maven-tools/flex-sdk-converter/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
@@ -52,6 +52,8 @@ public class FlexEventSpy extends AbstractEventSpy {
     protected boolean internalLookup = false;
     protected boolean flexSplashScreenShown = false;
 
+    protected ProxySettings proxySettings = null;
+
     public FlexEventSpy() {
     }
 
@@ -63,6 +65,31 @@ public class FlexEventSpy extends AbstractEventSpy {
     public void onEvent(Object o) throws Exception {
         if(o instanceof ExecutionEvent) {
             mavenSession = ((ExecutionEvent) o).getSession();
+
+            // Get proxy settings from the maven settings and save them in the
+            // ProxySettings "singleton".
+            org.apache.maven.settings.Proxy settingsProxy = 
mavenSession.getSettings().getActiveProxy();
+            if(settingsProxy != null) {
+                String protocol = settingsProxy.getProtocol();
+                String host = settingsProxy.getHost();
+                int port = settingsProxy.getPort();
+                String nonProxyHost = settingsProxy.getNonProxyHosts();
+                final String username = settingsProxy.getUsername();
+                final String password = settingsProxy.getPassword();
+                proxySettings = new ProxySettings(protocol, host, port, 
nonProxyHost, username, password);
+                ProxySettings.setProxySettings(proxySettings);
+                if (!StringUtils.isEmpty(proxySettings.getUsername()) &&
+                        !StringUtils.isEmpty(proxySettings.getPassword())) {
+                    Authenticator authenticator = new Authenticator() {
+                        @Override
+                        protected PasswordAuthentication 
getPasswordAuthentication() {
+                            return new 
PasswordAuthentication(proxySettings.getUsername(),
+                                    proxySettings.getPassword().toCharArray());
+                        }
+                    };
+                    Authenticator.setDefault(authenticator);
+                }
+            }
         } else if(o instanceof RepositoryEvent) {
             RepositoryEvent repositoryEvent = (RepositoryEvent) o;
             if(repositoryEvent.getType() == 
RepositoryEvent.EventType.ARTIFACT_RESOLVING) {
@@ -151,22 +178,6 @@ public class FlexEventSpy extends AbstractEventSpy {
         
logger.info("===========================================================");
         logger.info(" - Installing Apache Flex SDK " + version);
         try {
-            // Get proxy settings from the maven settings and save them in the
-            // ProxySettings "singleton".
-            final ProxySettings proxySettings = getProxySettings();
-            ProxySettings.setProxySettings(proxySettings);
-            if ((proxySettings != null) && 
!StringUtils.isEmpty(proxySettings.getUsername()) &&
-                    !StringUtils.isEmpty(proxySettings.getPassword())) {
-                Authenticator authenticator = new Authenticator() {
-                    @Override
-                    protected PasswordAuthentication 
getPasswordAuthentication() {
-                        return new 
PasswordAuthentication(proxySettings.getUsername(),
-                                proxySettings.getPassword().toCharArray());
-                    }
-                };
-                Authenticator.setDefault(authenticator);
-            }
-
             File localRepoBaseDir = new 
File(mavenSession.getLocalRepository().getBasedir());
             DownloadRetriever downloadRetriever = new DownloadRetriever();
             File sdkRoot = downloadRetriever.retrieve(SdkType.FLEX, version, 
null);
@@ -288,18 +299,4 @@ public class FlexEventSpy extends AbstractEventSpy {
         flexSplashScreenShown = true;
     }
 
-    protected ProxySettings getProxySettings() {
-        org.apache.maven.settings.Proxy settingsProxy = 
mavenSession.getSettings().getActiveProxy();
-        if(settingsProxy != null) {
-            String protocol = settingsProxy.getProtocol();
-            String host = settingsProxy.getHost();
-            int port = settingsProxy.getPort();
-            String nonProxyHost = settingsProxy.getNonProxyHosts();
-            final String username = settingsProxy.getUsername();
-            final String password = settingsProxy.getPassword();
-            return new ProxySettings(protocol, host, port, nonProxyHost, 
username, password);
-        }
-        return null;
-    }
-
 }

Reply via email to