You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2016/06/09 07:53:48 UTC

git commit: [flex-falcon] [refs/heads/develop] - - Added more config options to the plugin -- support of defining 'defines' in the pom -- fixed setting the default defines using the config-file instead of the commandline (The problems that I was having w

Repository: flex-falcon
Updated Branches:
  refs/heads/develop cf3dd695a -> 7c1c183b4


- Added more config options to the plugin
-- support of defining 'defines' in the pom
-- fixed setting the default defines using the config-file instead of the commandline (The problems that I was having were because I had 'AS' instead of 'AS3' in the constant)


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

Branch: refs/heads/develop
Commit: 7c1c183b457a5ca9a415f84e20633120073ee28c
Parents: cf3dd69
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Thu Jun 9 09:44:02 2016 +0200
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Thu Jun 9 09:44:02 2016 +0200

----------------------------------------------------------------------
 .../org/apache/flex/maven/flexjs/BaseMojo.java  | 27 +++++++++++++++-
 .../apache/flex/maven/flexjs/CompileASMojo.java | 16 ++++-----
 .../flex/maven/flexjs/CompileAppMojo.java       | 18 +++++------
 .../flex/maven/flexjs/CompileExternMojo.java    | 16 ++++-----
 .../apache/flex/maven/flexjs/CompileJSMojo.java |  8 +++++
 .../org/apache/flex/maven/flexjs/Define.java    | 34 ++++++++++++++++++++
 .../flex/maven/flexjs/GenerateExterncMojo.java  |  9 ++++++
 .../resources/config/compile-app-config.xml     | 11 +++----
 .../main/resources/config/compile-as-config.xml | 15 +++++----
 .../resources/config/compile-extern-config.xml  | 11 +++----
 .../main/resources/config/compile-js-config.xml | 11 +++----
 .../config/generate-externc-config.xml          | 11 +++----
 12 files changed, 125 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseMojo.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseMojo.java
index 1f99067..6cbaddb 100644
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseMojo.java
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseMojo.java
@@ -9,7 +9,8 @@ import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.*;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectDependenciesResolver;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
@@ -45,6 +46,9 @@ public abstract class BaseMojo
     private IncludeFile[] includeFiles;
 
     @Parameter
+    private Define[] defines;
+
+    @Parameter
     private String targetPlayer = "11.1";
 
     @Parameter
@@ -53,6 +57,9 @@ public abstract class BaseMojo
     @Parameter
     private boolean debug = false;
 
+    @Parameter
+    private Boolean includeLookupOnly = null;
+
     @Parameter(readonly = true, defaultValue = "${repositorySystemSession}")
     private RepositorySystemSession repositorySystemSession;
 
@@ -82,9 +89,13 @@ public abstract class BaseMojo
         context.put("namespaceUris", getNamespaceUris());
         context.put("includeClasses", includeClasses);
         context.put("includeFiles", includeFiles);
+        context.put("defines", getDefines());
         context.put("targetPlayer", targetPlayer);
         context.put("includeSources", includeSources);
         context.put("debug", debug);
+        if(includeLookupOnly != null) {
+            context.put("includeLookupOnly", includeLookupOnly);
+        }
         context.put("output", getOutput());
 
         return context;
@@ -136,6 +147,10 @@ public abstract class BaseMojo
     protected List<String> getCompilerArgs(File configFile) throws MojoExecutionException {
         List<String> args = new LinkedList<String>();
         args.add("-load-config=" + configFile.getPath());
+        // It seems we need to manually pass this as it is not picked up by the compiler from the config file -->
+        /*for(Define define : getDefines()) {
+            args.add("-define=" + define.getName() + "," + define.getValue());
+        }*/
         return args;
     }
 
@@ -211,6 +226,16 @@ public abstract class BaseMojo
         return externalLibraries;
     }
 
+    protected List<Define> getDefines() {
+        List<Define> defines = new LinkedList<Define>();
+        if(this.defines != null) {
+            for(Define define : this.defines) {
+                defines.add(define);
+            }
+        }
+        return defines;
+    }
+
     protected boolean includeLibrary(Artifact library) {
         return true;
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileASMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileASMojo.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileASMojo.java
index 17f453f..3a73f7c 100644
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileASMojo.java
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileASMojo.java
@@ -67,14 +67,6 @@ public class CompileASMojo
     }
 
     @Override
-    protected List<String> getCompilerArgs(File configFile) throws MojoExecutionException {
-        List<String> args = super.getCompilerArgs(configFile);
-        args.add("-define=COMPILE::AS3,true");
-        args.add("-define=COMPILE::JS,false");
-        return args;
-    }
-
-    @Override
     public void execute() throws MojoExecutionException {
         super.execute();
 
@@ -96,6 +88,14 @@ public class CompileASMojo
     }
 
     @Override
+    protected List<Define> getDefines() {
+        List<Define> defines = super.getDefines();
+        defines.add(new Define("COMPILE::JS", "false"));
+        defines.add(new Define("COMPILE::AS3", "true"));
+        return defines;
+    }
+
+    @Override
     protected boolean includeLibrary(Artifact library) {
         return !"extern".equalsIgnoreCase(library.getClassifier());
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileAppMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileAppMojo.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileAppMojo.java
index 0b8b9df..b65eaec 100644
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileAppMojo.java
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileAppMojo.java
@@ -16,22 +16,14 @@
 
 package org.apache.flex.maven.flexjs;
 
-import edu.emory.mathcs.backport.java.util.Arrays;
 import org.apache.flex.tools.FlexTool;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
 import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -81,8 +73,6 @@ public class CompileAppMojo
             throw new MojoExecutionException("Could not find main class");
         }
         List<String> args = super.getCompilerArgs(configFile);
-        args.add("-define=COMPILE::AS3,true");
-        args.add("-define=COMPILE::JS,false");
         args.add(mainClassPath);
         return args;
     }
@@ -145,6 +135,14 @@ public class CompileAppMojo
     }*/
 
     @Override
+    protected List<Define> getDefines() {
+        List<Define> defines = super.getDefines();
+        defines.add(new Define("COMPILE::JS", "false"));
+        defines.add(new Define("COMPILE::AS3", "true"));
+        return defines;
+    }
+
+    @Override
     protected boolean includeLibrary(Artifact library) {
         return !"extern".equalsIgnoreCase(library.getClassifier());
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileExternMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileExternMojo.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileExternMojo.java
index 393274c..3f7fe6c 100644
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileExternMojo.java
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileExternMojo.java
@@ -71,14 +71,6 @@ public class CompileExternMojo
     }
 
     @Override
-    protected List<String> getCompilerArgs(File configFile) throws MojoExecutionException {
-        List<String> args = super.getCompilerArgs(configFile);
-        args.add("-define=COMPILE::AS3,false");
-        args.add("-define=COMPILE::JS,true");
-        return args;
-    }
-
-    @Override
     public void execute() throws MojoExecutionException
     {
         super.execute();
@@ -101,6 +93,14 @@ public class CompileExternMojo
     }
 
     @Override
+    protected List<Define> getDefines() {
+        List<Define> defines = super.getDefines();
+        defines.add(new Define("COMPILE::JS", "true"));
+        defines.add(new Define("COMPILE::AS3", "false"));
+        return defines;
+    }
+
+    @Override
     protected boolean includeLibrary(Artifact library) {
         return "extern".equalsIgnoreCase(library.getClassifier());
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileJSMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileJSMojo.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileJSMojo.java
index c1298c0..86f68de 100644
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileJSMojo.java
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileJSMojo.java
@@ -98,6 +98,14 @@ public class CompileJSMojo
     }
 
     @Override
+    protected List<Define> getDefines() {
+        List<Define> defines = super.getDefines();
+        defines.add(new Define("COMPILE::JS", "true"));
+        defines.add(new Define("COMPILE::AS3", "false"));
+        return defines;
+    }
+
+    @Override
     protected boolean includeLibrary(Artifact library) {
         return "extern".equalsIgnoreCase(library.getClassifier());
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/Define.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/Define.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/Define.java
new file mode 100644
index 0000000..8a01894
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/Define.java
@@ -0,0 +1,34 @@
+package org.apache.flex.maven.flexjs;
+
+/**
+ * Created by christoferdutz on 07.06.16.
+ */
+public class Define {
+
+    private String name;
+    private String value;
+
+    public Define() {
+    }
+
+    public Define(String name, String value) {
+        this.name = name;
+        this.value = value;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/GenerateExterncMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/GenerateExterncMojo.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/GenerateExterncMojo.java
index f7d3d9e..32240f8 100644
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/GenerateExterncMojo.java
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/GenerateExterncMojo.java
@@ -101,4 +101,13 @@ public class GenerateExterncMojo
             }
         }
     }
+
+    @Override
+    protected List<Define> getDefines() {
+        List<Define> defines = super.getDefines();
+        defines.add(new Define("COMPILE::JS", "true"));
+        defines.add(new Define("COMPILE::AS3", "false"));
+        return defines;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/resources/config/compile-app-config.xml
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/resources/config/compile-app-config.xml b/flexjs-maven-plugin/src/main/resources/config/compile-app-config.xml
index 5729616..db5c53b 100644
--- a/flexjs-maven-plugin/src/main/resources/config/compile-app-config.xml
+++ b/flexjs-maven-plugin/src/main/resources/config/compile-app-config.xml
@@ -67,14 +67,11 @@
         <warn-no-constructor>false</warn-no-constructor>
         <show-deprecation-warnings>false</show-deprecation-warnings>
 
-        <define append="true">
-            <name>COMPILE::JS</name>
-            <value>false</value>
-        </define>
-        <define append="true">
-            <name>COMPILE::AS3</name>
-            <value>true</value>
+#foreach($define in $defines)        <define>
+            <name>$define.name</name>
+            <value>$define.value</value>
         </define>
+#end
     </compiler>
 
 #if($includeSources)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/resources/config/compile-as-config.xml
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/resources/config/compile-as-config.xml b/flexjs-maven-plugin/src/main/resources/config/compile-as-config.xml
index 1c9e1e2..5608c5f 100644
--- a/flexjs-maven-plugin/src/main/resources/config/compile-as-config.xml
+++ b/flexjs-maven-plugin/src/main/resources/config/compile-as-config.xml
@@ -67,14 +67,11 @@
         <warn-no-constructor>false</warn-no-constructor>
         <show-deprecation-warnings>false</show-deprecation-warnings>
 
-        <define append="true">
-            <name>COMPILE::JS</name>
-            <value>false</value>
-        </define>
-        <define append="true">
-            <name>COMPILE::AS3</name>
-            <value>true</value>
+#foreach($define in $defines)        <define>
+            <name>$define.name</name>
+            <value>$define.value</value>
         </define>
+#end
     </compiler>
 
 #if($includeSources)
@@ -104,6 +101,10 @@
     </include-file>
 #end
 
+#if($includeLookupOnly)
+    <include-lookup-only>$includeLookupOnly</include-lookup-only>
+#end
+
     <target-player>${targetPlayer}</target-player>
 
     <output>${output}</output>

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/resources/config/compile-extern-config.xml
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/resources/config/compile-extern-config.xml b/flexjs-maven-plugin/src/main/resources/config/compile-extern-config.xml
index ad2a205..2cacb7f 100644
--- a/flexjs-maven-plugin/src/main/resources/config/compile-extern-config.xml
+++ b/flexjs-maven-plugin/src/main/resources/config/compile-extern-config.xml
@@ -49,14 +49,11 @@
 
         <show-deprecation-warnings>false</show-deprecation-warnings>
 
-        <define append="true">
-            <name>COMPILE::JS</name>
-            <value>true</value>
-        </define>
-        <define append="true">
-            <name>COMPILE::AS3</name>
-            <value>false</value>
+#foreach($define in $defines)        <define>
+            <name>$define.name</name>
+            <value>$define.value</value>
         </define>
+#end
     </compiler>
 
 #if($includeSources)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/resources/config/compile-js-config.xml
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/resources/config/compile-js-config.xml b/flexjs-maven-plugin/src/main/resources/config/compile-js-config.xml
index 9e487e8..831cce8 100644
--- a/flexjs-maven-plugin/src/main/resources/config/compile-js-config.xml
+++ b/flexjs-maven-plugin/src/main/resources/config/compile-js-config.xml
@@ -65,14 +65,11 @@
 
         <show-deprecation-warnings>false</show-deprecation-warnings>
 
-        <define append="true">
-            <name>COMPILE::JS</name>
-            <value>true</value>
-        </define>
-        <define append="true">
-            <name>COMPILE::AS3</name>
-            <value>false</value>
+#foreach($define in $defines)        <define>
+            <name>$define.name</name>
+            <value>$define.value</value>
         </define>
+#end
     </compiler>
 
 #if($includeSources)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7c1c183b/flexjs-maven-plugin/src/main/resources/config/generate-externc-config.xml
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/resources/config/generate-externc-config.xml b/flexjs-maven-plugin/src/main/resources/config/generate-externc-config.xml
index 53a8c53..1455a00 100644
--- a/flexjs-maven-plugin/src/main/resources/config/generate-externc-config.xml
+++ b/flexjs-maven-plugin/src/main/resources/config/generate-externc-config.xml
@@ -19,14 +19,11 @@
 <flex-config>
 
     <compiler>
-        <define append="true">
-            <name>COMPILE::JS</name>
-            <value>true</value>
-        </define>
-        <define append="true">
-            <name>COMPILE::AS3</name>
-            <value>false</value>
+#foreach($define in $defines)        <define>
+            <name>$define.name</name>
+            <value>$define.value</value>
         </define>
+#end
     </compiler>
 
     <external>