You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2019/12/10 17:38:25 UTC

[royale-compiler] branch develop updated: royale-maven-plugin: Copies mxml-2009-manifest.xml from resource instead of hard-coding it (references #103)

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new 924cde5  royale-maven-plugin: Copies mxml-2009-manifest.xml from resource instead of hard-coding it (references #103)
924cde5 is described below

commit 924cde58927b688a2e291d0ed134ae2665438c48
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue Dec 10 09:38:18 2019 -0800

    royale-maven-plugin: Copies mxml-2009-manifest.xml from resource instead of hard-coding it (references #103)
---
 .../java/org/apache/royale/maven/BaseMojo.java     | 29 ++++++++-------
 .../main/resources/config/mxml-2009-manifest.xml   | 42 ++++++++++++++++++++++
 2 files changed, 59 insertions(+), 12 deletions(-)

diff --git a/royale-maven-plugin/src/main/java/org/apache/royale/maven/BaseMojo.java b/royale-maven-plugin/src/main/java/org/apache/royale/maven/BaseMojo.java
index 6cf3509..1322f89 100644
--- a/royale-maven-plugin/src/main/java/org/apache/royale/maven/BaseMojo.java
+++ b/royale-maven-plugin/src/main/java/org/apache/royale/maven/BaseMojo.java
@@ -118,11 +118,6 @@ public abstract class BaseMojo
         return "http://ns.adobe.com/mxml/2009";
     }
 
-    protected String getLanguageManifestContents()
-    {
-        return "<?xml version=\"1.0\"?>\n<componentPackage>\n<component id=\"Array\" class=\"Array\" lookupOnly=\"true\"/>\n<component id=\"Boolean\" class=\"Boolean\" lookupOnly=\"true\"/>\n<component id=\"Class\" class=\"Class\" lookupOnly=\"true\"/>\n<component id=\"Date\" class=\"Date\" lookupOnly=\"true\"/>\n<component id=\"DesignLayer\" class=\"mx.core.DesignLayer\"/>\n<component id=\"Function\" class=\"Function\" lookupOnly=\"true\"/>\n<component id=\"int\" class=\"int\" lookupOnl [...]
-    }
-
     protected VelocityContext getVelocityContext() throws MojoExecutionException {
         VelocityContext context = new VelocityContext();
 
@@ -292,14 +287,15 @@ public abstract class BaseMojo
             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();
+        
+        // Prepare the config file.
+        File configFile = new File(outputDirectory, getConfigFileName());
+        Template configTemplate = velocityEngine.getTemplate("config/" + getConfigFileName());
 
         if(!configFile.getParentFile().exists()) {
             if(!configFile.getParentFile().mkdirs()) {
@@ -309,7 +305,7 @@ public abstract class BaseMojo
         FileWriter writer = null;
         try {
             writer = new FileWriter(configFile);
-            template.merge(context, writer);
+            configTemplate.merge(context, writer);
         } catch (IOException e) {
             throw new MojoExecutionException("Error creating config file at " + configFile.getPath());
         } finally {
@@ -321,18 +317,27 @@ public abstract class BaseMojo
                 }
             }
         }
+
+        // Prepare the MXML language manifest file.
         File manifestFile = new File(outputDirectory, getLanguageManifestFileName());
+        Template manifestTemplate = velocityEngine.getTemplate("config/" + getLanguageManifestFileName());
+
+        if(!manifestFile.getParentFile().exists()) {
+            if(!manifestFile.getParentFile().mkdirs()) {
+                throw new MojoExecutionException("Could not create output directory: " + manifestFile.getParent());
+            }
+        }
         try {
             writer = new FileWriter(manifestFile);
-            writer.write(getLanguageManifestContents());
+            manifestTemplate.merge(context, writer);
         } catch (IOException e) {
-            throw new MojoExecutionException("Error creating config file at " + configFile.getPath());
+            throw new MojoExecutionException("Error creating manifest file at " + manifestFile.getPath());
         } finally {
             if(writer != null) {
                 try {
                     writer.close();
                 } catch (IOException e) {
-                    throw new MojoExecutionException("Error creating config file at " + configFile.getPath());
+                    throw new MojoExecutionException("Error creating manifest file at " + manifestFile.getPath());
                 }
             }
         }
diff --git a/royale-maven-plugin/src/main/resources/config/mxml-2009-manifest.xml b/royale-maven-plugin/src/main/resources/config/mxml-2009-manifest.xml
new file mode 100644
index 0000000..0d5294f
--- /dev/null
+++ b/royale-maven-plugin/src/main/resources/config/mxml-2009-manifest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+
+  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.
+
+-->
+<!--
+
+    MXML 2009 Components
+
+-->
+<componentPackage>
+    <!-- AS3 built-ins -->
+    <component id="Array" class="Array" lookupOnly="true"/>
+    <component id="Boolean" class="Boolean" lookupOnly="true"/>
+    <component id="Class" class="Class" lookupOnly="true"/>
+    <component id="Date" class="Date" lookupOnly="true"/>
+    <component id="DesignLayer" class="mx.core.DesignLayer"/>
+    <component id="Function" class="Function" lookupOnly="true"/>
+    <component id="int" class="int" lookupOnly="true"/>
+    <component id="Number" class="Number" lookupOnly="true"/>
+    <component id="Object" class="Object" lookupOnly="true"/>
+    <component id="RegExp" class="RegExp" lookupOnly="true"/>
+    <component id="String" class="String" lookupOnly="true"/>
+    <component id="uint" class="uint" lookupOnly="true"/>
+    <component id="Vector" class="__AS3__.vec.Vector" lookupOnly="true"/>
+    <component id="XML" class="XML" lookupOnly="true"/>
+    <component id="XMLList" class="XMLList" lookupOnly="true"/>
+</componentPackage>
\ No newline at end of file