- Cleaned up the code a little.

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

Branch: refs/heads/as3httpclient-work
Commit: bfe6ba997093ac3dc7ab315605332a954b0220ed
Parents: 34ba2e8
Author: Christofer Dutz <[email protected]>
Authored: Sun Apr 19 12:17:24 2015 +0200
Committer: Christofer Dutz <[email protected]>
Committed: Sun Apr 19 12:17:24 2015 +0200

----------------------------------------------------------------------
 .../converter/mavenextension/FlexEventSpy.java  | 32 ++++++++++++--------
 1 file changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/bfe6ba99/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
----------------------------------------------------------------------
diff --git 
a/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
 
b/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
index a378f98..f275677 100644
--- 
a/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
+++ 
b/mavenizer/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
@@ -24,6 +24,11 @@ import javax.inject.Singleton;
 import java.io.File;
 
 /**
+ * Maven EventSpy that listens for resolution requests and in case of Flex 
related
+ * artifacts, it pre-checks their availability. If they are not available, it 
uses
+ * the apache flex sdk converter to automatically download and convert the 
missing
+ * artifacts before continuing the build normally.
+ *
  * Created by christoferdutz on 17.04.15.
  */
 @Named
@@ -60,26 +65,27 @@ public class FlexEventSpy extends AbstractEventSpy {
                         internalLookup = true;
                         Artifact artifact = repositoryEvent.getArtifact();
                         if 
(artifact.getGroupId().startsWith("org.apache.flex")) {
+                            // Output a cool spash-screen ... sorry for that 
... couldn't resist :-)
                             if(!flexSplashScreenShown) {
                                 showFlexSplashScreen();
                             }
-                            if(resolve(artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getVersion(),
-                                    artifact.getExtension(), 
artifact.getClassifier()) == null) {
+                            if(!canResolve(artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getVersion(),
+                                    artifact.getExtension(), 
artifact.getClassifier())) {
                                 initFlex(artifact.getVersion());
                             }
                         } else if 
(artifact.getGroupId().startsWith("com.adobe.flash")) {
-                            if(resolve(artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getVersion(),
-                                    artifact.getExtension(), 
artifact.getClassifier()) == null) {
+                            if(!canResolve(artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getVersion(),
+                                    artifact.getExtension(), 
artifact.getClassifier())) {
                                 initFlash(artifact.getVersion());
                             }
                         } else if 
(artifact.getGroupId().startsWith("com.adobe.air")) {
-                            if(resolve(artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getVersion(),
-                                    artifact.getExtension(), 
artifact.getClassifier()) == null) {
+                            if(!canResolve(artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getVersion(),
+                                    artifact.getExtension(), 
artifact.getClassifier())) {
                                 initAir(artifact.getVersion());
                             }
                         } else if (artifact.getGroupId().equals("com.adobe") 
&& artifact.getArtifactId().equals("fontkit")) {
-                            if(resolve(artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getVersion(),
-                                    artifact.getExtension(), 
artifact.getClassifier()) == null) {
+                            if(!canResolve(artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getVersion(),
+                                    artifact.getExtension(), 
artifact.getClassifier())) {
                                 initFontkit();
                             }
                         }
@@ -91,8 +97,8 @@ public class FlexEventSpy extends AbstractEventSpy {
         }
     }
 
-    protected org.apache.maven.artifact.Artifact resolve(String groupId, 
String artifactId, String version,
-                                                         String type, String 
classifier) {
+    protected boolean canResolve(String groupId, String artifactId, String 
version,
+                                                            String type, 
String classifier) {
         org.apache.maven.artifact.Artifact artifact;
         if((classifier == null) || (classifier.length() == 0)) {
             artifact = repositorySystem.createArtifact(groupId, artifactId, 
version, type);
@@ -107,13 +113,13 @@ public class FlexEventSpy extends AbstractEventSpy {
                 
req.setRemoteRepositories(mavenSession.getRequest().getRemoteRepositories());
                 ArtifactResolutionResult res = repositorySystem.resolve(req);
                 if (!res.isSuccess()) {
-                    return null;
+                    return false;
                 }
             } catch (Exception e) {
-                return null;
+                return false;
             }
         }
-        return artifact;
+        return true;
     }
 
     protected void initFlex(String version) throws MavenExecutionException {

Reply via email to