royale-maven-plugin: can build with playerglobalc
diff --git a/royale-maven-plugin/src/main/java/org/apache/royale/maven/CompilePlayerglobalMojo.java b/royale-maven-plugin/src/main/java/org/apache/royale/maven/CompilePlayerglobalMojo.java
new file mode 100644
index 0000000..bbf13b7
--- /dev/null
+++ b/royale-maven-plugin/src/main/java/org/apache/royale/maven/CompilePlayerglobalMojo.java
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+package org.apache.royale.maven;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.flex.tools.FlexTool;
+import org.apache.maven.artifact.Artifact;
+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;
+
+/**
+ * goal which compiles a project into a playerglobal swc library.
+ */
+@Mojo(name="compile-playerglobal",defaultPhase = LifecyclePhase.PROCESS_SOURCES)
+public class CompilePlayerglobalMojo
+ extends BaseMojo
+{
+ @Parameter(defaultValue = "src/main/asdoc")
+ private String asdocDirectoryName;
+
+ @Parameter(defaultValue = "${project.artifactId}-${project.version}.swc")
+ protected String outputFileName;
+
+ @Parameter(defaultValue = "false")
+ private boolean skipPlayerglobal;
+
+ @Component
+ private MavenProjectHelper projectHelper;
+
+ @Override
+ protected String getToolGroupName() {
+ return "Royale";
+ }
+
+ @Override
+ protected String getFlexTool() {
+ return FlexTool.FLEX_TOOL_COMPC;
+ }
+
+ @Override
+ protected String getConfigFileName() throws MojoExecutionException {
+ return "compile-playerglobal-config.xml";
+ }
+
+ protected File getOutput() throws MojoExecutionException {
+ return new File(outputDirectory, outputFileName);
+ }
+
+ @Override
+ protected List<String> getCompilerArgs(File configFile) throws MojoExecutionException {
+ List<String> args = super.getCompilerArgs(configFile);
+ args.add("-compiler.targets=SWF");
+ return args;
+ }
+
+ @Override
+ protected boolean skip() {
+ if(skipPlayerglobal) {
+ return true;
+ }
+ File inputFolder = new File(asdocDirectoryName);
+ return !inputFolder.exists() || !inputFolder.isDirectory();
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException
+ {
+ super.execute();
+
+ if(getOutput().exists()) {
+ // Add the extern to the artifact.
+ projectHelper.attachArtifact(project, getOutput(), "typedefs");
+ }
+ }
+
+ @Override
+ protected List<Define> getDefines() throws MojoExecutionException {
+ List<Define> defines = super.getDefines();
+ defines.add(new Define("COMPILE::JS", "false"));
+ defines.add(new Define("COMPILE::SWF", "true"));
+ return defines;
+ }
+
+ @Override
+ protected boolean includeLibrary(Artifact library) {
+ return "typedefs".equalsIgnoreCase(library.getClassifier());
+ }
+
+}
diff --git a/royale-maven-plugin/src/main/java/org/apache/royale/maven/GeneratePlayerglobalMojo.java b/royale-maven-plugin/src/main/java/org/apache/royale/maven/GeneratePlayerglobalMojo.java
new file mode 100644
index 0000000..23fd6f2
--- /dev/null
+++ b/royale-maven-plugin/src/main/java/org/apache/royale/maven/GeneratePlayerglobalMojo.java
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+package org.apache.royale.maven;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+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.velocity.VelocityContext;
+
+/**
+ */
+@Mojo(name="generate-playerglobal",defaultPhase = LifecyclePhase.PROCESS_SOURCES)
+public class GeneratePlayerglobalMojo
+ extends BaseMojo
+{
+ @Parameter(defaultValue = "src/main/asdoc")
+ private String asdocDirectoryName;
+
+ @Parameter(defaultValue = "generated-sources/playerglobal")
+ private String outputDirectoryName;
+
+ @Parameter(defaultValue = "false")
+ private boolean skipPlayerglobal;
+
+ @Override
+ protected String getToolGroupName() {
+ return "Royale";
+ }
+
+ @Override
+ protected String getFlexTool() {
+ return "PLAYERGLOBALC";
+ }
+
+ @Override
+ protected String getConfigFileName() throws MojoExecutionException {
+ return "generate-playerglobal-config.xml";
+ }
+
+ @Override
+ protected File getOutput() throws MojoExecutionException {
+ return new File(outputDirectory, outputDirectoryName);
+ }
+
+ @Override
+ protected VelocityContext getVelocityContext() throws MojoExecutionException {
+ VelocityContext context = super.getVelocityContext();
+ context.put("asdocRoot", new File(asdocDirectoryName));
+ return context;
+ }
+
+ @Override
+ protected boolean skip() {
+ if(skipPlayerglobal) {
+ return true;
+ }
+ File inputFolder = new File(asdocDirectoryName);
+ return !inputFolder.exists() || !inputFolder.isDirectory();
+ }
+
+ @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()) {
+ project.addCompileSourceRoot(outputDirectory.getPath());
+ }
+ }
+
+}
diff --git a/royale-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/royale-maven-plugin/src/main/resources/META-INF/plexus/components.xml
index 436822b..15b1809 100644
--- a/royale-maven-plugin/src/main/resources/META-INF/plexus/components.xml
+++ b/royale-maven-plugin/src/main/resources/META-INF/plexus/components.xml
@@ -32,7 +32,8 @@
<phases>
<!-- Generate ActionScript from JavaScript -->
<generate-sources>
- org.apache.royale.compiler:royale-maven-plugin:generate-extern
+ org.apache.royale.compiler:royale-maven-plugin:generate-extern,
+ org.apache.royale.compiler:royale-maven-plugin:generate-playerglobal,
</generate-sources>
<!--
Generate JavaScript sources from the ActionScript sources.
@@ -47,6 +48,7 @@
org.apache.royale.compiler:royale-maven-plugin:compile-as,
org.apache.royale.compiler:royale-maven-plugin:compile-js,
org.apache.royale.compiler:royale-maven-plugin:compile-extern,
+ org.apache.royale.compiler:royale-maven-plugin:compile-playerglobal,
</compile>
<process-test-resources>
org.apache.maven.plugins:maven-resources-plugin:testResources
diff --git a/royale-maven-plugin/src/main/resources/config/compile-playerglobal-config.xml b/royale-maven-plugin/src/main/resources/config/compile-playerglobal-config.xml
new file mode 100644
index 0000000..5bb1c99
--- /dev/null
+++ b/royale-maven-plugin/src/main/resources/config/compile-playerglobal-config.xml
@@ -0,0 +1,101 @@
+<!--
+
+ 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.
+
+-->
+<royale-config>
+
+ <compiler>
+
+ <accessible>false</accessible>
+ <debug>$debug</debug>
+
+ <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>
+
+ <namespaces>
+#foreach($namespace in $namespaces) <namespace>
+ <uri>$namespace.uri</uri>
+ <manifest>$namespace.manifest</manifest>
+ </namespace>
+#end
+#if($languageNamespace)
+ <namespace>
+ <uri>$languageNamespace.uri</uri>
+ <manifest>$languageNamespace.manifest</manifest>
+ </namespace>
+#end
+ </namespaces>
+
+ <warn-no-constructor>false</warn-no-constructor>
+
+ <mxml>
+ <children-as-data>true</children-as-data>
+ </mxml>
+
+ <show-deprecation-warnings>false</show-deprecation-warnings>
+
+#foreach($define in $defines) <define>
+ <name>$define.name</name>
+ <value>$define.value</value>
+ </define>
+#end
+
+ <strict-xml>true</strict-xml>
+ </compiler>
+
+#if($includeSources)
+ <include-sources>
+#foreach($sourcePath in $sourcePaths) <path-element>$sourcePath</path-element>
+#end
+ </include-sources>
+#end
+
+#if($includeClasses)
+ <include-classes>
+#foreach($includeClass in $includeClasses) <class>$includeClass</class>
+#end
+ </include-classes>
+#end
+
+#if($namespaceUris)
+ <include-namespaces>
+#foreach($namespaceUri in $namespaceUris) <uri>$namespaceUri</uri>
+#end
+ </include-namespaces>
+#end
+
+#foreach($includeFile in $includeFiles) <include-file>
+ <name>$includeFile.name</name>
+ <path>$includeFile.path</path>
+ </include-file>
+#end
+
+ <output>${output}</output>
+
+</royale-config>
diff --git a/royale-maven-plugin/src/main/resources/config/generate-playerglobal-config.xml b/royale-maven-plugin/src/main/resources/config/generate-playerglobal-config.xml
new file mode 100644
index 0000000..b8b00e5
--- /dev/null
+++ b/royale-maven-plugin/src/main/resources/config/generate-playerglobal-config.xml
@@ -0,0 +1,22 @@
+<!--
+
+ 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.
+
+-->
+<royale-config>
+ <as-root>${output.path}</as-root>
+ <asdoc-root>${asdocRoot.path}</asdoc-root>
+</royale-config>