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/05/01 19:20:01 UTC
git commit: [flex-falcon] [refs/heads/develop] - - Implemented a new
plugin that now -- completely generates the config files needed to compile.
-- consists of 4 goals: CompileAS, CompileJS,
CompileExtern and GenerateExtern - Adjusted the extern poms to
Repository: flex-falcon
Updated Branches:
refs/heads/develop c093ecdb4 -> aac6c2211
- Implemented a new plugin that now
-- completely generates the config files needed to compile.
-- consists of 4 goals: CompileAS, CompileJS, CompileExtern and GenerateExtern
- Adjusted the extern poms to use the new plugin version
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/aac6c221
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/aac6c221
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/aac6c221
Branch: refs/heads/develop
Commit: aac6c221120ccc027b5244a4a8e88da2033373ef
Parents: c093ecd
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Sun May 1 19:19:52 2016 +0200
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Sun May 1 19:19:52 2016 +0200
----------------------------------------------------------------------
externs/GCL/pom.xml | 1 +
externs/cordova/pom.xml | 26 ++-
externs/createjs/pom.xml | 43 ++++-
externs/google_maps/pom.xml | 11 +-
externs/jasmine/pom.xml | 23 ++-
externs/jquery/pom.xml | 72 +++++++-
externs/js/pom.xml | 80 +++++++-
externs/node/pom.xml | 45 ++++-
flexjs-maven-plugin/pom.xml | 12 ++
.../flex/maven/flexjs/BaseCompileMojo.java | 183 +------------------
.../org/apache/flex/maven/flexjs/BaseMojo.java | 183 +++++++++++++++++++
.../apache/flex/maven/flexjs/ClassExclude.java | 18 ++
.../apache/flex/maven/flexjs/CompileASMojo.java | 34 ++--
.../flex/maven/flexjs/CompileExternMojo.java | 71 +++++++
.../apache/flex/maven/flexjs/CompileJSMojo.java | 50 ++---
.../org/apache/flex/maven/flexjs/Exclude.java | 26 +++
.../apache/flex/maven/flexjs/ExterncConfig.java | 14 ++
.../apache/flex/maven/flexjs/ExterncMojo.java | 62 -------
.../apache/flex/maven/flexjs/FieldExclude.java | 26 +++
.../flex/maven/flexjs/GenerateExterncMojo.java | 104 +++++++++++
.../resources/META-INF/plexus/components.xml | 14 +-
.../main/resources/config/compile-as-config.xml | 104 +++++++++++
.../resources/config/compile-extern-config.xml | 59 ++++++
.../main/resources/config/compile-js-config.xml | 108 +++++++++++
.../config/generate-externc-config.xml | 55 ++++++
25 files changed, 1132 insertions(+), 292 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/externs/GCL/pom.xml
----------------------------------------------------------------------
diff --git a/externs/GCL/pom.xml b/externs/GCL/pom.xml
index 0854ced..f603ac4 100644
--- a/externs/GCL/pom.xml
+++ b/externs/GCL/pom.xml
@@ -34,6 +34,7 @@
<name>Apache Flex - FlexJS: Externs: GCL</name>
<build>
+ <sourceDirectory>src/main/flex</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.flex.flexjs.compiler</groupId>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/externs/cordova/pom.xml
----------------------------------------------------------------------
diff --git a/externs/cordova/pom.xml b/externs/cordova/pom.xml
index 225eddd..6ce7a99 100644
--- a/externs/cordova/pom.xml
+++ b/externs/cordova/pom.xml
@@ -45,8 +45,15 @@
<version>0.6.0-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
- <toolGroupName>Falcon</toolGroupName>
- </configuration>
+ <externcInput>
+ <fileSet>
+ <directory>${project.basedir}/src/main/javascript</directory>
+ <includes>
+ <include>**/*.js</include>
+ </includes>
+ </fileSet>
+ </externcInput>
+ </configuration>
<dependencies>
<dependency>
<groupId>org.apache.flex.flexjs.compiler</groupId>
@@ -66,6 +73,21 @@
<type>swc</type>
<scope>external</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.flex.flexjs.externs</groupId>
+ <artifactId>flexjs-externs-js</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <type>swc</type>
+ <scope>external</scope>
+ </dependency>
+ <!-- this is not on external-library path otherwise goog.requires are not generated -->
+ <dependency>
+ <groupId>org.apache.flex.flexjs.externs</groupId>
+ <artifactId>flexjs-externs-gcl</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <type>swc</type>
+ </dependency>
+
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/externs/createjs/pom.xml
----------------------------------------------------------------------
diff --git a/externs/createjs/pom.xml b/externs/createjs/pom.xml
index 8f2251c..d156412 100644
--- a/externs/createjs/pom.xml
+++ b/externs/createjs/pom.xml
@@ -180,7 +180,48 @@
<version>0.6.0-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
- <toolGroupName>Falcon</toolGroupName>
+ <externcInput>
+ <fileSet>
+ <directory>${project.basedir}/src/main/javascript</directory>
+ <includes>
+ <include>**/*.js</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/target/downloads/EaselJS-${createjs.version}/src</directory>
+ <includes>
+ <include>**/*.js</include>
+ </includes>
+ <excludes>
+ <exclude>version.js</exclude>
+ <exclude>version_movieclip.js</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/target/downloads/TweenJS-${tweenjs.version}/src</directory>
+ <includes>
+ <include>tweenjs/Ease.js</include>
+ <include>tweenjs/Timeline.js</include>
+ <include>tweenjs/Tween.js</include>
+ </includes>
+ </fileSet>
+ </externcInput>
+ <externcConfig>
+ <class-excludes>
+ <class-exclude>
+ <className>MovieClipPlugin</className>
+ </class-exclude>
+ <class-exclude>
+ <className>createjs.Text.V_OFFSETS</className>
+ </class-exclude>
+ <class-exclude>
+ <className>createjs.Text.H_OFFSETS</className>
+ </class-exclude>
+ <class-exclude>
+ <className>createjs.Graphics.BASE_64</className>
+ </class-exclude>
+ </class-excludes>
+ </externcConfig>
</configuration>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/externs/google_maps/pom.xml
----------------------------------------------------------------------
diff --git a/externs/google_maps/pom.xml b/externs/google_maps/pom.xml
index 43b8c7a..57617b9 100644
--- a/externs/google_maps/pom.xml
+++ b/externs/google_maps/pom.xml
@@ -93,8 +93,15 @@ google.maps = {};]]></replace></replace-regexp-operation>
<version>0.6.0-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
- <toolGroupName>Falcon</toolGroupName>
- </configuration>
+ <externcInput>
+ <fileSet>
+ <directory>${project.basedir}/target/downloads</directory>
+ <includes>
+ <include>**/*.js</include>
+ </includes>
+ </fileSet>
+ </externcInput>
+ </configuration>
<dependencies>
<dependency>
<groupId>org.apache.flex.flexjs.compiler</groupId>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/externs/jasmine/pom.xml
----------------------------------------------------------------------
diff --git a/externs/jasmine/pom.xml b/externs/jasmine/pom.xml
index 9a028f1..2fe300c 100644
--- a/externs/jasmine/pom.xml
+++ b/externs/jasmine/pom.xml
@@ -65,7 +65,28 @@
<version>0.6.0-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
- <toolGroupName>Falcon</toolGroupName>
+ <externcInput>
+ <fileSet>
+ <directory>${project.basedir}/target/downloads</directory>
+ <includes>
+ <include>**/*.js</include>
+ </includes>
+ </fileSet>
+ </externcInput>
+ <externcConfig>
+ <field-excludes>
+ <field-exclude>
+ <className>jasmine.Spec</className>
+ <field>$injector</field>
+ </field-exclude>
+ </field-excludes>
+ <excludes>
+ <exclude>
+ <className>jasmine.Matchers</className>
+ <name>actual</name>
+ </exclude>
+ </excludes>
+ </externcConfig>
</configuration>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/externs/jquery/pom.xml
----------------------------------------------------------------------
diff --git a/externs/jquery/pom.xml b/externs/jquery/pom.xml
index b71dd18..1240a19 100644
--- a/externs/jquery/pom.xml
+++ b/externs/jquery/pom.xml
@@ -87,7 +87,77 @@
<version>0.6.0-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
- <toolGroupName>Falcon</toolGroupName>
+ <externcInput>
+ <fileSet>
+ <directory>${project.basedir}/target/downloads</directory>
+ <includes>
+ <include>**/*.js</include>
+ </includes>
+ </fileSet>
+ </externcInput>
+ <externcConfig>
+ <!-- JQuery -->
+ <!--class-to-function><class>$</class></class-to-function-->
+
+ <class-excludes>
+ <class-exclude>
+ <className>Deferred</className>
+ </class-exclude>
+ <class-exclude>
+ <className>jQuery.deferred</className>
+ </class-exclude>
+ <class-exclude>
+ <className>jQuery.Event</className>
+ </class-exclude>
+ <class-exclude>
+ <className>jQuery.Deferred</className>
+ </class-exclude>
+ <class-exclude>
+ <className>$.Event</className>
+ </class-exclude>
+ <class-exclude>
+ <className>$.Deferred</className>
+ </class-exclude>
+ <class-exclude>
+ <className>$.deferred</className>
+ </class-exclude>
+ </class-excludes>
+
+ <excludes>
+ <exclude>
+ <className>jQuery</className>
+ <name>is</name>
+ </exclude>
+ <exclude>
+ <className>jQuery</className>
+ <name>promise</name>
+ </exclude>
+ <exclude>
+ <className>jQuery</className>
+ <name>getJSON</name>
+ </exclude>
+ <exclude>
+ <className>jQuery</className>
+ <name>ajax</name>
+ </exclude>
+ <exclude>
+ <className>jQuery</className>
+ <name>when</name>
+ </exclude>
+ <exclude>
+ <className>jQuery</className>
+ <name>post</name>
+ </exclude>
+ <exclude>
+ <className>jQuery</className>
+ <name>getScript</name>
+ </exclude>
+ <exclude>
+ <className>jQuery</className>
+ <name>Callbacks</name>
+ </exclude>
+ </excludes>
+ </externcConfig>
</configuration>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/externs/js/pom.xml
----------------------------------------------------------------------
diff --git a/externs/js/pom.xml b/externs/js/pom.xml
index 964b875..b012d90 100644
--- a/externs/js/pom.xml
+++ b/externs/js/pom.xml
@@ -124,7 +124,85 @@
<version>0.6.0-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
- <toolGroupName>Falcon</toolGroupName>
+ <externcInput>
+ <fileSet>
+ <directory>${project.basedir}/src/main/javascript</directory>
+ <includes>
+ <include>**/*.js</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/target/downloads</directory>
+ <includes>
+ <include>*.js</include>
+ <include>browser/w3c_*.js</include>
+ <include>browser/window.js</include>
+ <include>browser/ie_dom.js</include>
+ <include>browser/gecko_*.js</include>
+ <include>browser/webkit_*.js</include>
+ <include>browser/iphone.js</include>
+ <include>browser/chrome.js</include>
+ <include>browser/flash.js</include>
+ <include>browser/page_visibility.js</include>
+ <include>browser/fileapi.js</include>
+ <include>browser/html5.js</include>
+ <include>browser/webgl.js</include>
+ <include>browser/webstorage.js</include>
+ </includes>
+ <excludes>
+ <exclude>es6_collections.js</exclude>
+ <exclude>browser/w3c_serviceworker.js</exclude>
+ <exclude>browser/w3c_touch_event.js</exclude>
+ <exclude>browser/w3c_webcrypto.js</exclude>
+ <exclude>browser/gecko_css.js</exclude>
+ <exclude>browser/webkit_notifications.js</exclude>
+ </excludes>
+ </fileSet>
+ </externcInput>
+ <externcConfig>
+ <class-excludes>
+ <class-exclude>
+ <className>controlRange</className>
+ </class-exclude>
+ </class-excludes>
+ <field-excludes>
+ <field-exclude>
+ <className>Window</className>
+ <field>focus</field>
+ </field-exclude>
+ </field-excludes>
+ <excludes>
+ <exclude>
+ <className>Array</className>
+ <name>toSource</name>
+ </exclude>
+ <exclude>
+ <className>Date</className>
+ <name>valueOf</name>
+ </exclude>
+ <exclude>
+ <className>String</className>
+ <name>valueOf</name>
+ </exclude>
+ <!-- SVG -->
+ <exclude>
+ <className>SVGStylable</className>
+ <name>className</name>
+ </exclude>
+ <exclude>
+ <className>SVGStylable</className>
+ <name>style</name>
+ </exclude>
+ <exclude>
+ <className>SVGLocatable</className>
+ <name>farthestViewportElement</name>
+ </exclude>
+ <exclude>
+ <className>SVGLocatable</className>
+ <name>nearestViewportElement</name>
+ </exclude>
+ </excludes>
+ </externcConfig>
</configuration>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/externs/node/pom.xml
----------------------------------------------------------------------
diff --git a/externs/node/pom.xml b/externs/node/pom.xml
index 39dd3c7..9cc6d4f 100644
--- a/externs/node/pom.xml
+++ b/externs/node/pom.xml
@@ -67,7 +67,28 @@
<version>0.6.0-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
- <toolGroupName>Falcon</toolGroupName>
+ <externcInput>
+ <fileSet>
+ <directory>${project.basedir}/src/main/javascript</directory>
+ <includes>
+ <include>**/*.js</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/target/downloads/closure-compiler-master/contrib/nodejs</directory>
+ <includes>
+ <include>**/*.js</include>
+ </includes>
+ </fileSet>
+ </externcInput>
+ <externcConfig>
+ <excludes>
+ <exclude>
+ <className>Buffer</className>
+ <name>toJSON</name>
+ </exclude>
+ </excludes>
+ </externcConfig>
</configuration>
<dependencies>
<dependency>
@@ -88,6 +109,28 @@
<type>swc</type>
<scope>external</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.flex.flexjs.framework</groupId>
+ <artifactId>Core</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <type>swc</type>
+ <classifier>extern</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.flex.flexjs.externs</groupId>
+ <artifactId>flexjs-externs-js</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <type>swc</type>
+ <scope>external</scope>
+ </dependency>
+ <!-- this is not on external-library path otherwise goog.requires are not generated -->
+ <dependency>
+ <groupId>org.apache.flex.flexjs.externs</groupId>
+ <artifactId>flexjs-externs-gcl</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <type>swc</type>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/flexjs-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/pom.xml b/flexjs-maven-plugin/pom.xml
index ed82859..87bf654 100644
--- a/flexjs-maven-plugin/pom.xml
+++ b/flexjs-maven-plugin/pom.xml
@@ -51,6 +51,13 @@
<scope>provided</scope>
</dependency>
+ <!-- Apache Velocity templating engine for generating config files -->
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.7</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
@@ -62,6 +69,11 @@
<version>${maven.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>file-management</artifactId>
+ <version>3.0.0</version>
+ </dependency>
+ <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseCompileMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseCompileMojo.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseCompileMojo.java
index 92e548f..39a5556 100644
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseCompileMojo.java
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseCompileMojo.java
@@ -1,189 +1,24 @@
package org.apache.flex.maven.flexjs;
-import org.apache.flex.maven.flexjs.types.FlexScope;
import org.apache.flex.tools.FlexTool;
-import org.apache.flex.tools.FlexToolGroup;
-import org.apache.flex.tools.FlexToolRegistry;
-import org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.Artifact;
-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.eclipse.aether.RepositorySystemSession;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
+import org.apache.velocity.VelocityContext;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.xpath.*;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.Set;
/**
- * Created by christoferdutz on 22.04.16.
+ * Created by christoferdutz on 30.04.16.
*/
-public abstract class BaseCompileMojo
- extends AbstractMojo
-{
+public abstract class BaseCompileMojo extends BaseMojo {
- @Parameter(defaultValue = "${project}", readonly = true)
- protected MavenProject project;
-
- @Parameter(defaultValue="${project.build.directory}")
- protected File outputDirectory;
-
- @Parameter(defaultValue = "FlexJS")
- protected String toolGroupName;
-
- @Parameter(readonly = true, defaultValue = "${repositorySystemSession}")
- private RepositorySystemSession repositorySystemSession;
-
- @Component
- private ProjectDependenciesResolver projectDependenciesResolver;
-
- protected abstract File getConfigFile();
-
- protected abstract String[] getCompilerArgs(File configFile);
-
- public void execute()
- throws MojoExecutionException
- {
- File configFile = getConfigFile();
- if(!configFile.exists()) {
- getLog().info(" - compilation config file '" + configFile.getPath() +
- "' not found, skipping compilation");
- return;
- }
-
- // Prepare the config file.
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- try {
- // Resolve all the dependencies.
- Set<Artifact> resolvedDependencies = resolveDependencies();
-
- // Parse the input document.
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document configuration = builder.parse(new FileInputStream(configFile));
-
- // Append the path-elements for the compile scope.
- Set<Artifact> compileDependencies = getDependenciesForScope(resolvedDependencies, FlexScope.COMPILE);
- outputLibraryPath(configuration, "flex-config/compiler/library-path", compileDependencies);
-
- // Append the path-elements for the external scope.
- Set<Artifact> externalDependencies = getDependenciesForScope(resolvedDependencies, FlexScope.EXTERNAL);
- outputLibraryPath(configuration, "flex-config/compiler/external-library-path", externalDependencies);
-
- // Write the modified config-file to the output directory.
- File configFileOutput = new File(outputDirectory, configFile.getName());
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- DOMSource source = new DOMSource(configuration);
- StreamResult result = new StreamResult(configFileOutput);
- transformer.transform(source, result);
-
- // Get the falcon tool group.
- FlexToolRegistry toolRegistry = new FlexToolRegistry();
- FlexToolGroup toolGroup = toolRegistry.getToolGroup(toolGroupName);
- if(toolGroup == null) {
- throw new MojoExecutionException("Could not find tool group: Falcon");
- }
-
- // Get an instance of the compiler and run the build.
- FlexTool compc = toolGroup.getFlexTool(FlexTool.FLEX_TOOL_COMPC);
- compc.execute(getCompilerArgs(configFileOutput));
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (TransformerConfigurationException e) {
- e.printStackTrace();
- } catch (TransformerException e) {
- e.printStackTrace();
- }
- }
-
- private Set<Artifact> resolveDependencies() throws MojoExecutionException {
- DefaultDependencyResolutionRequest dependencyResolutionRequest =
- new DefaultDependencyResolutionRequest(project, repositorySystemSession);
- DependencyResolutionResult dependencyResolutionResult;
-
- try {
- dependencyResolutionResult = projectDependenciesResolver.resolve(dependencyResolutionRequest);
- } catch (DependencyResolutionException ex) {
- throw new MojoExecutionException(ex.getMessage(), ex);
- }
-
- Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
- if (dependencyResolutionResult.getDependencyGraph() != null
- && !dependencyResolutionResult.getDependencyGraph().getChildren().isEmpty()) {
- RepositoryUtils.toArtifacts(artifacts, dependencyResolutionResult.getDependencyGraph().getChildren(),
- Collections.singletonList(project.getArtifact().getId()), null);
- }
- return artifacts;
+ @Override
+ protected String getToolGroupName() {
+ return "Falcon";
}
- private Set<Artifact> getDependenciesForScope(Set<Artifact> dependencies, FlexScope scope) {
- Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
- for(Artifact dependency : dependencies) {
- FlexScope dependencyScope = FlexScope.COMPILE;
- if(dependency.getScope() != null) {
- dependencyScope = FlexScope.valueOf(dependency.getScope().toUpperCase());
- }
- if(dependencyScope == scope) {
- artifacts.add(dependency);
- }
- }
- return artifacts;
- }
-
- private void outputLibraryPath(Document configDocument, String baseXPath, Set<Artifact> artifacts) {
- if(!artifacts.isEmpty()) {
- XPathFactory xPathfactory = XPathFactory.newInstance();
- XPath xpath = xPathfactory.newXPath();
- try {
- XPathExpression expr = xpath.compile(baseXPath);
- Element externalLibraryPath = (Element) expr.evaluate(configDocument, XPathConstants.NODE);
- if(externalLibraryPath != null) {
- // Remove any existing path-elements (They are leftovers from the ant build).
- Node child = externalLibraryPath.getFirstChild();
- while(child != null) {
- externalLibraryPath.removeChild(child);
- child = externalLibraryPath.getFirstChild();
- }
-
- // Add the new path-elements.
- for (Artifact artifact : artifacts) {
- Element newPathElement = configDocument.createElement("path-element");
- newPathElement.setTextContent(artifact.getFile().getAbsolutePath());
- externalLibraryPath.appendChild(newPathElement);
- }
- } else {
- throw new RuntimeException("Could not find root element " + baseXPath);
- }
- } catch (XPathExpressionException e) {
- throw new RuntimeException("Error adding path-element", e);
- }
- }
+ @Override
+ protected String getFlexTool() {
+ return FlexTool.FLEX_TOOL_COMPC;
}
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/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
new file mode 100644
index 0000000..a77c0a1
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/BaseMojo.java
@@ -0,0 +1,183 @@
+package org.apache.flex.maven.flexjs;
+
+import org.apache.flex.tools.FlexTool;
+import org.apache.flex.tools.FlexToolGroup;
+import org.apache.flex.tools.FlexToolRegistry;
+import org.apache.maven.RepositoryUtils;
+import org.apache.maven.artifact.Artifact;
+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.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.eclipse.aether.RepositorySystemSession;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Created by christoferdutz on 22.04.16.
+ */
+public abstract class BaseMojo
+ extends AbstractMojo
+{
+
+ @Parameter(defaultValue = "${project}", readonly = true)
+ protected MavenProject project;
+
+ @Parameter(defaultValue="${project.build.directory}")
+ protected File outputDirectory;
+
+ @Parameter
+ private String targetPlayer = "11.1";
+
+ @Parameter
+ private boolean debug = false;
+
+ @Parameter(readonly = true, defaultValue = "${repositorySystemSession}")
+ private RepositorySystemSession repositorySystemSession;
+
+ @Component
+ private ProjectDependenciesResolver projectDependenciesResolver;
+
+ protected boolean skip() {
+ return false;
+ }
+
+ protected abstract String getConfigFileName();
+
+ protected abstract File getOutput();
+
+ protected VelocityContext getVelocityContext() throws MojoExecutionException {
+ VelocityContext context = new VelocityContext();
+
+ List<Artifact> allLibraries = getAllLibraries();
+ List<Artifact> libraries = getLibraries(allLibraries);
+ List<Artifact> externalLibraries = getExternalLibraries(allLibraries);
+ List<String> sourcePaths = getSourcePaths();
+ context.put("libraries", libraries);
+ context.put("externalLibraries", externalLibraries);
+ context.put("sourcePaths", sourcePaths);
+ context.put("targetPlayer", targetPlayer);
+ context.put("debug", debug);
+ context.put("output", getOutput());
+
+ return context;
+ }
+
+ protected abstract String getToolGroupName();
+
+ protected abstract String getFlexTool();
+
+ @SuppressWarnings("unchecked")
+ protected List<String> getSourcePaths() {
+ List<String> sourcePaths = new LinkedList<String>();
+ for(String sourcerPath : (List<String>) project.getCompileSourceRoots()) {
+ if(new File(sourcerPath).exists()) {
+ sourcePaths.add(sourcerPath);
+ }
+ }
+ return sourcePaths;
+ }
+
+ protected List<String> getCompilerArgs(File configFile) {
+ List<String> args = new LinkedList<String>();
+ args.add("-load-config=" + configFile.getPath());
+ return args;
+ }
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ // Skip this step if not all preconditions are met.
+ if(skip()) {
+ return;
+ }
+
+ // Prepare the config file.
+ File configFile = new File(outputDirectory, getConfigFileName());
+ VelocityEngine velocityEngine = new VelocityEngine();
+ velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+ velocityEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+ velocityEngine.init();
+ Template template = velocityEngine.getTemplate("config/" + getConfigFileName());
+ VelocityContext context = getVelocityContext();
+ FileWriter writer = null;
+ try {
+ writer = new FileWriter(configFile);
+ template.merge(context, writer);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Error creating config file at " + configFile.getPath());
+ } finally {
+ if(writer != null) {
+ try {
+ writer.close();
+ } catch (IOException e) {
+ throw new MojoExecutionException("Error creating config file at " + configFile.getPath());
+ }
+ }
+ }
+
+ // Get the tool group.
+ FlexToolRegistry toolRegistry = new FlexToolRegistry();
+ FlexToolGroup toolGroup = toolRegistry.getToolGroup(getToolGroupName());
+ if(toolGroup == null) {
+ throw new MojoExecutionException("Could not find tool group: " + getToolGroupName());
+ }
+
+ // Get an instance of the compiler and run the build.
+ FlexTool tool = toolGroup.getFlexTool(getFlexTool());
+ tool.execute(getCompilerArgs(configFile).toArray(new String[0]));
+ }
+
+ protected List<Artifact> getLibraries(List<Artifact> artifacts) {
+ List<Artifact> libraries = new LinkedList<Artifact>();
+ for(Artifact artifact : artifacts) {
+ if(!"external".equalsIgnoreCase(artifact.getScope())) {
+ libraries.add(artifact);
+ }
+ }
+ return libraries;
+ }
+
+ protected List<Artifact> getExternalLibraries(List<Artifact> artifacts) {
+ List<Artifact> externalLibraries = new LinkedList<Artifact>();
+ for(Artifact artifact : artifacts) {
+ if("external".equalsIgnoreCase(artifact.getScope())) {
+ externalLibraries.add(artifact);
+ }
+ }
+ return externalLibraries;
+ }
+
+ private List<Artifact> getAllLibraries() throws MojoExecutionException {
+ DefaultDependencyResolutionRequest dependencyResolutionRequest =
+ new DefaultDependencyResolutionRequest(project, repositorySystemSession);
+ DependencyResolutionResult dependencyResolutionResult;
+
+ try {
+ dependencyResolutionResult = projectDependenciesResolver.resolve(dependencyResolutionRequest);
+ } catch (DependencyResolutionException ex) {
+ throw new MojoExecutionException(ex.getMessage(), ex);
+ }
+
+ List<Artifact> artifacts = new LinkedList<Artifact>();
+ if (dependencyResolutionResult.getDependencyGraph() != null
+ && !dependencyResolutionResult.getDependencyGraph().getChildren().isEmpty()) {
+ RepositoryUtils.toArtifacts(artifacts, dependencyResolutionResult.getDependencyGraph().getChildren(),
+ Collections.singletonList(project.getArtifact().getId()), null);
+ }
+ return artifacts;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ClassExclude.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ClassExclude.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ClassExclude.java
new file mode 100644
index 0000000..61bdd84
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ClassExclude.java
@@ -0,0 +1,18 @@
+package org.apache.flex.maven.flexjs;
+
+/**
+ * Created by christoferdutz on 01.05.16.
+ */
+public class ClassExclude {
+
+ private String className;
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/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 ad18d5b..aec0e7d 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
@@ -16,6 +16,7 @@
package org.apache.flex.maven.flexjs;
+import org.apache.flex.tools.FlexTool;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
@@ -28,36 +29,45 @@ import java.io.File;
*/
@Mojo(name="compile-as",defaultPhase = LifecyclePhase.PROCESS_SOURCES)
public class CompileASMojo
- extends BaseCompileMojo
+ extends BaseMojo
{
- @Parameter(defaultValue="${basedir}/src/main/config/compile-as-config.xml")
- private File compileAsConfigFile;
-
@Parameter(defaultValue = "${project.artifactId}-${project.version}.swc")
private String outputFileName;
@Override
- protected File getConfigFile() {
- return compileAsConfigFile;
+ protected String getToolGroupName() {
+ return "Falcon";
+ }
+
+ @Override
+ protected String getFlexTool() {
+ return FlexTool.FLEX_TOOL_COMPC;
+ }
+
+ @Override
+ protected String getConfigFileName() {
+ return "compile-as-config.xml";
}
- private File getOutputFile() {
+ @Override
+ protected File getOutput() {
return new File(outputDirectory, outputFileName);
}
@Override
- protected String[] getCompilerArgs(File configFile) {
- return new String[]{"-debug", "-load-config=" + configFile.getPath(),
- "-output=" + getOutputFile().getPath(), "-define=COMPILE::AS3,true", "-define=COMPILE::JS,false"};
+ protected boolean skip() {
+ return true;
}
@Override
public void execute() throws MojoExecutionException {
super.execute();
- if(getOutputFile().exists()) {
+
+ if(getOutput().exists()) {
// Attach the file created by the compiler as artifact file to maven.
- project.getArtifact().setFile(getOutputFile());
+ project.getArtifact().setFile(getOutput());
}
}
+
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/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
new file mode 100644
index 0000000..6ad8669
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileExternMojo.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flex.maven.flexjs;
+
+import org.apache.flex.tools.FlexTool;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProjectHelper;
+
+import java.io.File;
+
+/**
+ * goal which compiles a project into a flexjs swc library.
+ */
+@Mojo(name="compile-extern",defaultPhase = LifecyclePhase.PROCESS_SOURCES)
+public class CompileExternMojo
+ extends BaseMojo
+{
+
+ @Parameter(defaultValue = "${project.artifactId}-${project.version}-extern.swc")
+ protected String outputFileName;
+
+ @Component
+ private MavenProjectHelper projectHelper;
+
+ @Override
+ protected String getToolGroupName() {
+ return "Falcon";
+ }
+
+ @Override
+ protected String getFlexTool() {
+ return FlexTool.FLEX_TOOL_COMPC;
+ }
+
+ @Override
+ protected String getConfigFileName() {
+ return "compile-extern-config.xml";
+ }
+
+ protected File getOutput() {
+ return new File(outputDirectory, outputFileName);
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException
+ {
+ super.execute();
+
+ // Add the extern to the artifact.
+ projectHelper.attachArtifact(project, getOutput(), "extern");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/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 620a4ea..89b66c9 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
@@ -16,7 +16,7 @@
package org.apache.flex.maven.flexjs;
-import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.flex.tools.FlexTool;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
@@ -28,50 +28,34 @@ import java.io.File;
*/
@Mojo(name="compile-js",defaultPhase = LifecyclePhase.PROCESS_SOURCES)
public class CompileJSMojo
- extends BaseCompileMojo
+ extends BaseMojo
{
- @Parameter(defaultValue="${basedir}/src/main/config/compile-js-config.xml")
- private File compileJsConfigFile;
-
- @Parameter(defaultValue = "${project.artifactId}-${project.version}.swc")
- private String outputFileName;
+ @Parameter(defaultValue = "${project.artifactId}-${project.version}")
+ private String outputDirectoryName;
@Override
- protected File getConfigFile() {
- return compileJsConfigFile;
+ protected String getToolGroupName() {
+ return "FlexJS";
}
- private File getOutputDirectory() {
- return new File(outputDirectory, "generated-sources/flexjs");
+ @Override
+ protected String getFlexTool() {
+ return FlexTool.FLEX_TOOL_COMPC;
}
@Override
- protected String[] getCompilerArgs(File configFile) {
- return new String[] {"-js-output-type=FLEXJS", "-keep-asdoc", "-load-config=" + configFile.getPath(),
- "-output=" + new File(outputDirectory.getPath(), "generated-sources/flexjs").getPath(),
- "-define=COMPILE::AS3,false", "-define=COMPILE::JS,true"};
+ protected String getConfigFileName() {
+ return "compile-js-config.xml";
}
@Override
- public void execute() throws MojoExecutionException
- {
- if(!compileJsConfigFile.exists()) {
- getLog().info(" - compilation config file '" + compileJsConfigFile.getPath() +
- "' not found, skipping compilation");
- return;
- }
-
- File generatedSourcesOutputDir = getOutputDirectory();
- if(!generatedSourcesOutputDir.exists()) {
- if(!generatedSourcesOutputDir.mkdirs()) {
- throw new MojoExecutionException("Could not create directory " + generatedSourcesOutputDir.getPath());
- }
- }
-
- super.execute();
-
- // TODO: Add Source directory
+ protected File getOutput() {
+ return new File(outputDirectory, outputDirectoryName);
}
+ @Override
+ protected boolean skip() {
+ return true;
+ }
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/Exclude.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/Exclude.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/Exclude.java
new file mode 100644
index 0000000..06afa34
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/Exclude.java
@@ -0,0 +1,26 @@
+package org.apache.flex.maven.flexjs;
+
+/**
+ * Created by christoferdutz on 01.05.16.
+ */
+public class Exclude {
+
+ private String className;
+ private String name;
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncConfig.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncConfig.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncConfig.java
new file mode 100644
index 0000000..ed48710
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncConfig.java
@@ -0,0 +1,14 @@
+package org.apache.flex.maven.flexjs;
+
+/**
+ * Created by christoferdutz on 01.05.16.
+ */
+public class ExterncConfig {
+
+ public ClassExclude[] classExcludes;
+
+ public FieldExclude[] fieldExcludes;
+
+ public Exclude[] excludes;
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncMojo.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncMojo.java
deleted file mode 100644
index dd14db5..0000000
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncMojo.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flex.maven.flexjs;
-
-import org.apache.flex.tools.FlexTool;
-import org.apache.flex.tools.FlexToolGroup;
-import org.apache.flex.tools.FlexToolRegistry;
-import org.apache.maven.plugin.AbstractMojo;
-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 java.io.File;
-
-/**
- * goal which generates actionscript code from javascript.
- */
-@Mojo(name="generate-extern",defaultPhase = LifecyclePhase.PROCESS_SOURCES)
-public class ExterncMojo
- extends AbstractMojo
-{
-
- @Parameter(defaultValue="${basedir}/src/main/config/externc-config.xml")
- private File configFile;
-
- public void execute()
- throws MojoExecutionException
- {
- if(!configFile.exists()) {
- getLog().info("Skipping Generation of ActionScript code due to missing config file: " +
- configFile.getPath());
- return;
- }
-
- FlexToolRegistry toolRegistry = new FlexToolRegistry();
- FlexToolGroup toolGroup = toolRegistry.getToolGroup("FlexJS");
- if(toolGroup == null) {
- throw new MojoExecutionException("Could not find tool group: FlexJS");
- }
-
- // TODO: Change this to a flex-tool-api constant ...
- FlexTool compc = toolGroup.getFlexTool("EXTERNC");
- String[] args = {"+flexlib=externs", "-debug", "-load-config=" + configFile.getPath()};
- compc.execute(args);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FieldExclude.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FieldExclude.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FieldExclude.java
new file mode 100644
index 0000000..f3a665b
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FieldExclude.java
@@ -0,0 +1,26 @@
+package org.apache.flex.maven.flexjs;
+
+/**
+ * Created by christoferdutz on 01.05.16.
+ */
+public class FieldExclude {
+
+ private String className;
+ private String field;
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getField() {
+ return field;
+ }
+
+ public void setField(String field) {
+ this.field = field;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/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
new file mode 100644
index 0000000..f7d3d9e
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/GenerateExterncMojo.java
@@ -0,0 +1,104 @@
+package org.apache.flex.maven.flexjs;
+
+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.apache.maven.shared.model.fileset.FileSet;
+import org.apache.maven.shared.model.fileset.util.FileSetManager;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.velocity.VelocityContext;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Created by christoferdutz on 30.04.16.
+ */
+@Mojo(name="generate-extern",defaultPhase = LifecyclePhase.PROCESS_SOURCES)
+public class GenerateExterncMojo
+ extends BaseMojo
+{
+
+ @Parameter
+ private FileSet[] externcInput;
+
+ @Parameter(defaultValue = "generated-sources/externc")
+ private String outputDirectoryName;
+
+ @Parameter
+ private ExterncConfig externcConfig;
+
+ @Override
+ protected String getToolGroupName() {
+ return "FlexJS";
+ }
+
+ @Override
+ protected String getFlexTool() {
+ return "EXTERNC";
+ }
+
+ @Override
+ protected String getConfigFileName() {
+ return "generate-externc-config.xml";
+ }
+
+ @Override
+ protected boolean skip() {
+ return externcInput == null;
+ }
+
+ @Override
+ protected File getOutput() {
+ return new File(outputDirectory, outputDirectoryName);
+ }
+
+ @Override
+ protected VelocityContext getVelocityContext() throws MojoExecutionException {
+ VelocityContext context = super.getVelocityContext();
+
+ List<File> includedFiles = new LinkedList<File>();
+ FileSetManager fileSetManager = new FileSetManager();
+ for(FileSet fileSet : externcInput) {
+ String[] fileSetIncludes = fileSetManager.getIncludedFiles(fileSet);
+ if((fileSetIncludes != null) && (fileSetIncludes.length > 0)) {
+ for(String include : fileSetIncludes) {
+ includedFiles.add(new File(fileSet.getDirectory(), include));
+ }
+ }
+ }
+ context.put("sourcePath", includedFiles);
+ if(externcConfig != null) {
+ context.put("classExcludes", externcConfig.classExcludes);
+ context.put("fieldExcludes", externcConfig.fieldExcludes);
+ context.put("excludes", externcConfig.excludes);
+ }
+
+ return context;
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException {
+ File outputDirectory = getOutput();
+ if(!outputDirectory.exists()) {
+ if(!outputDirectory.mkdirs()) {
+ throw new MojoExecutionException("Could not create output directory " + outputDirectory.getPath());
+ }
+ }
+
+ super.execute();
+
+ // Add eventually generated source paths to the project.
+ if(outputDirectory.exists()) {
+ File[] typeDirectories = outputDirectory.listFiles();
+ if(typeDirectories != null) {
+ for (File typeDirectory : typeDirectories) {
+ project.addCompileSourceRoot(typeDirectory.getPath());
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
index c84be9c..28f01bb 100644
--- a/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
+++ b/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
@@ -12,15 +12,25 @@
<lifecycle>
<id>default</id>
<phases>
+ <!-- Generate ActionScript from JavaScript -->
<generate-sources>
org.apache.flex.flexjs.compiler:flexjs-maven-plugin:generate-extern
</generate-sources>
+ <!--
+ Generate JavaScript sources from the ActionScript sources.
+ Moved to the process-sources phase as we might want to generate
+ JavaScript from generated sources.
+ -->
+ <process-sources>
+ org.apache.flex.flexjs.compiler:flexjs-maven-plugin:compile-js
+ </process-sources>
<process-resources>
org.apache.maven.plugins:maven-resources-plugin:resources
</process-resources>
+ <!-- Compile the ActionScript to Flash (SWC) -->
<compile>
- org.apache.flex.flexjs.compiler:flexjs-maven-plugin:compile-js,
- org.apache.flex.flexjs.compiler:flexjs-maven-plugin:compile-as
+ org.apache.flex.flexjs.compiler:flexjs-maven-plugin:compile-as,
+ org.apache.flex.flexjs.compiler:flexjs-maven-plugin:compile-extern,
</compile>
<process-test-resources>
org.apache.maven.plugins:maven-resources-plugin:testResources
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/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
new file mode 100644
index 0000000..7c5bedb
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/resources/config/compile-as-config.xml
@@ -0,0 +1,104 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<flex-config>
+
+ <compiler>
+
+ <accessible>true</accessible>
+
+ <library-path>
+ #foreach($artifact in $libraries)<path-element>$artifact.file</path-element>#end
+ </library-path>
+
+ <external-library-path>
+ #foreach($artifact in $externalLibraries)<path-element>$artifact.file</path-element>#end
+ </external-library-path>
+
+ <namespaces>
+ <namespace>
+ <uri>library://ns.adobe.com/flex/spark</uri>
+ <manifest>manifest.xml</manifest>
+ </namespace>
+ </namespaces>
+
+ <keep-as3-metadata>
+ <name>SkinPart</name>
+ </keep-as3-metadata>
+
+ <mxml>
+ <minimum-supported-version>4.0.0</minimum-supported-version>
+ </mxml>
+
+ <locale/>
+
+ <source-path>
+ <path-element>../src/main/flex</path-element>
+ <path-element>generated-sources/externc/classes</path-element>
+ <path-element>generated-sources/externc/interfaces</path-element>
+ <path-element>generated-sources/externc/constants</path-element>
+ <path-element>generated-sources/externc/functions</path-element>
+ <path-element>generated-sources/externc/interfaces</path-element>
+ <path-element>generated-sources/externc/typedefs</path-element>
+ </source-path>
+
+ <warn-no-constructor>false</warn-no-constructor>
+
+ <define append="true">
+ <name>COMPILE::JS</name>
+ <value>false</value>
+ </define>
+ <define append="true">
+ <name>COMPILE::AS3</name>
+ <value>true</value>
+ </define>
+ </compiler>
+
+ <include-sources>
+ <!--path-element>../src/main/flex</path-element>
+ <path-element>generated-sources/externc/classes</path-element>
+ <path-element>generated-sources/externc/interfaces</path-element>
+ <path-element>generated-sources/externc/constants</path-element>
+ <path-element>generated-sources/externc/functions</path-element>
+ <path-element>generated-sources/externc/interfaces</path-element>
+ <path-element>generated-sources/externc/typedefs</path-element-->
+ </include-sources>
+
+ <!--
+ <include-file>
+ <name>defaults.css</name>
+ <path>defaults.css</path>
+ </include-file>
+ <include-file>
+ <name>assets/ErrorIndicator.png</name>
+ <path>assets/ErrorIndicator.png</path>
+ </include-file>
+ <include-file>
+ <name>assets/RequiredIndicator.png</name>
+ <path>assets/RequiredIndicator.png</path>
+ </include-file>
+
+ <include-namespaces>
+ <uri>library://ns.adobe.com/flex/spark</uri>
+ </include-namespaces>
+
+ <resource-bundle-list>bundles.properties</resource-bundle-list>
+
+ <target-player>${playerglobal.version}</target-player>
+ -->
+</flex-config>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/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
new file mode 100644
index 0000000..abd46df
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/resources/config/compile-extern-config.xml
@@ -0,0 +1,59 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<flex-config>
+
+ <compiler>
+
+ <accessible>true</accessible>
+
+ <library-path>
+#foreach($artifact in $libraries) <path-element>$artifact.file</path-element>
+#end
+ </library-path>
+
+ <external-library-path>
+#foreach($artifact in $externalLibraries) <path-element>$artifact.file</path-element>
+#end
+ </external-library-path>
+
+ <source-path>
+#foreach($sourcePath in $sourcePaths) <path-element>$sourcePath</path-element>
+#end
+ </source-path>
+
+ <warn-no-constructor>false</warn-no-constructor>
+
+ <define append="true">
+ <name>COMPILE::JS</name>
+ <value>true</value>
+ </define>
+ <define append="true">
+ <name>COMPILE::AS3</name>
+ <value>false</value>
+ </define>
+ </compiler>
+
+ <include-sources>
+#foreach($sourcePath in $sourcePaths) <path-element>$sourcePath</path-element>
+#end
+ </include-sources>
+
+ <output>${output}</output>
+
+</flex-config>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/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
new file mode 100644
index 0000000..8674369
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/resources/config/compile-js-config.xml
@@ -0,0 +1,108 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<flex-config>
+
+ <compiler>
+
+ <accessible>true</accessible>
+
+ <library-path>
+ #foreach($artifact in $libraries)<path-element>$artifact.file</path-element>#end
+ </library-path>
+
+ <external-library-path>
+ #foreach($artifact in $externalLibraries)<path-element>$artifact.file</path-element>#end
+ </external-library-path>
+
+ <namespaces>
+ <namespace>
+ <uri>library://ns.adobe.com/flex/spark</uri>
+ <manifest>manifest.xml</manifest>
+ </namespace>
+ </namespaces>
+
+ <keep-as3-metadata>
+ <name>SkinPart</name>
+ </keep-as3-metadata>
+
+ <mxml>
+ <minimum-supported-version>4.0.0</minimum-supported-version>
+ </mxml>
+
+ <locale/>
+
+ <source-path>
+ <path-element>../src/main/flex</path-element>
+ <path-element>generated-sources/externc/classes</path-element>
+ <path-element>generated-sources/externc/interfaces</path-element>
+ <path-element>generated-sources/externc/constants</path-element>
+ <path-element>generated-sources/externc/functions</path-element>
+ <path-element>generated-sources/externc/interfaces</path-element>
+ <path-element>generated-sources/externc/typedefs</path-element>
+ </source-path>
+
+ <warn-no-constructor>false</warn-no-constructor>
+
+ <define append="true">
+ <name>COMPILE::JS</name>
+ <value>true</value>
+ </define>
+ <define append="true">
+ <name>COMPILE::AS3</name>
+ <value>false</value>
+ </define>
+
+ <js-output-type>FLEXJS</js-output-type>
+
+ <keep-asdoc>true</keep-asdoc>
+ </compiler>
+
+ <include-sources>
+ <!--path-element>../src/main/flex</path-element>
+ <path-element>generated-sources/externc/classes</path-element>
+ <path-element>generated-sources/externc/interfaces</path-element>
+ <path-element>generated-sources/externc/constants</path-element>
+ <path-element>generated-sources/externc/functions</path-element>
+ <path-element>generated-sources/externc/interfaces</path-element>
+ <path-element>generated-sources/externc/typedefs</path-element-->
+ </include-sources>
+
+ <!--
+ <include-file>
+ <name>defaults.css</name>
+ <path>defaults.css</path>
+ </include-file>
+ <include-file>
+ <name>assets/ErrorIndicator.png</name>
+ <path>assets/ErrorIndicator.png</path>
+ </include-file>
+ <include-file>
+ <name>assets/RequiredIndicator.png</name>
+ <path>assets/RequiredIndicator.png</path>
+ </include-file>
+
+ <include-namespaces>
+ <uri>library://ns.adobe.com/flex/spark</uri>
+ </include-namespaces>
+
+ <resource-bundle-list>bundles.properties</resource-bundle-list>
+
+ <target-player>${playerglobal.version}</target-player>
+ -->
+</flex-config>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/aac6c221/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
new file mode 100644
index 0000000..5162714
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/resources/config/generate-externc-config.xml
@@ -0,0 +1,55 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License") you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<flex-config>
+
+ <compiler>
+ <define append="true">
+ <name>COMPILE::JS</name>
+ <value>true</value>
+ </define>
+ <define append="true">
+ <name>COMPILE::AS3</name>
+ <value>false</value>
+ </define>
+ </compiler>
+
+ <external>
+#foreach($source in $sourcePath) <path-element>${source.path}</path-element>#end
+ </external>
+
+ <as-root>${output.path}</as-root>
+
+ #foreach($classExclude in $classExcludes)<class-exclude>
+ <class>${classExclude.className}</class>
+ </class-exclude>
+ #end
+
+ #foreach($fieldExclude in $fieldExcludes)<field-exclude>
+ <class>${fieldExclude.className}</class>
+ <field>${fieldExclude.field}</field>
+ </field-exclude>
+ #end
+
+ #foreach($exclude in $excludes)<exclude>
+ <class>${exclude.className}</class>
+ <name>${exclude.name}</name>
+ </exclude>
+ #end
+
+</flex-config>