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

commit 1a74cf9a1cc8dbf8711894930d3eae7f48a37daa
Author: Josh Tynjala <[email protected]>
AuthorDate: Wed Mar 26 09:55:59 2025 -0700

    MXMLRoyalePublisher: instead of copying js/css/assets from all SWCs, copy 
only from those with reachable compilation units
    
    Previously, files were copied from all SWCs on the library-path, even if 
they were not actually used in the final compilation.
---
 compiler-jx/.classpath                             | 57 ++++++++++++++++++++--
 compiler-jx/.project                               | 21 ++++++--
 .../codegen/mxml/royale/MXMLRoyalePublisher.java   | 25 ++++++++--
 3 files changed, 92 insertions(+), 11 deletions(-)

diff --git a/compiler-jx/.classpath b/compiler-jx/.classpath
index 3922f1541..190ac5dfc 100644
--- a/compiler-jx/.classpath
+++ b/compiler-jx/.classpath
@@ -1,9 +1,29 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry kind="src" path="src/main/java"/>
-       <classpathentry kind="src" path="src/test/java"/>
-       <classpathentry kind="src" path="src/main/resources"/>
-       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="src" output="target/classes" path="src/main/java">
+               <attributes>
+                       <attribute name="optional" value="true"/>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="src" output="target/test-classes" 
path="src/test/java">
+               <attributes>
+                       <attribute name="optional" value="true"/>
+                       <attribute name="maven.pomderived" value="true"/>
+                       <attribute name="test" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry excluding="**" kind="src" output="target/classes" 
path="src/main/resources">
+               <attributes>
+                       <attribute name="maven.pomderived" value="true"/>
+                       <attribute name="optional" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
+               <attributes>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
        <classpathentry combineaccessrules="false" kind="src" path="/compiler"/>
        <classpathentry kind="lib" 
path="lib/google/closure-compiler/compiler.jar"/>
        <classpathentry kind="lib" path="lib/commons-io.jar"/>
@@ -18,5 +38,34 @@
        <classpathentry combineaccessrules="false" kind="src" 
path="/compiler-externc"/>
        <classpathentry combineaccessrules="false" kind="src" 
path="/compiler-test-utils"/>
        <classpathentry kind="lib" 
path="/compiler-externc/target/test-classes"/>
+       <classpathentry excluding="**" kind="src" output="target/test-classes" 
path="src/test/resources">
+               <attributes>
+                       <attribute name="maven.pomderived" value="true"/>
+                       <attribute name="test" value="true"/>
+                       <attribute name="optional" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="con" 
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+               <attributes>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="src" path="target/generated-sources/annotations">
+               <attributes>
+                       <attribute name="optional" value="true"/>
+                       <attribute name="maven.pomderived" value="true"/>
+                       <attribute name="ignore_optional_problems" 
value="true"/>
+                       <attribute name="m2e-apt" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="src" output="target/test-classes" 
path="target/generated-test-sources/test-annotations">
+               <attributes>
+                       <attribute name="optional" value="true"/>
+                       <attribute name="maven.pomderived" value="true"/>
+                       <attribute name="ignore_optional_problems" 
value="true"/>
+                       <attribute name="m2e-apt" value="true"/>
+                       <attribute name="test" value="true"/>
+               </attributes>
+       </classpathentry>
        <classpathentry kind="output" path="target/classes"/>
 </classpath>
diff --git a/compiler-jx/.project b/compiler-jx/.project
index ce368b36f..fd0f999ec 100644
--- a/compiler-jx/.project
+++ b/compiler-jx/.project
@@ -10,12 +10,25 @@
                        <arguments>
                        </arguments>
                </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
        </buildSpec>
        <natures>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
-       <linkedResources>
-       </linkedResources>
-       <variableList>
-       </variableList>
+       <filteredResources>
+               <filter>
+                       <id>1741709744933</id>
+                       <name></name>
+                       <type>30</type>
+                       <matcher>
+                               
<id>org.eclipse.core.resources.regexFilterMatcher</id>
+                               
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
+                       </matcher>
+               </filter>
+       </filteredResources>
 </projectDescription>
diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
index d90cde607..ff024e350 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
@@ -47,8 +47,10 @@ import 
org.apache.royale.compiler.internal.graph.GoogDepsWriter;
 import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
 import 
org.apache.royale.compiler.internal.scopes.ASProjectScope.DefinitionPromise;
 import org.apache.royale.compiler.internal.targets.ITargetAttributes;
+import org.apache.royale.compiler.internal.units.SWCCompilationUnit;
 import org.apache.royale.compiler.problems.FileNotFoundProblem;
 import org.apache.royale.compiler.problems.HTMLTemplateFileNotFoundProblem;
+import org.apache.royale.compiler.units.ICompilationUnit;
 import org.apache.royale.compiler.utils.JSClosureCompilerWrapper;
 import org.apache.royale.swc.ISWC;
 import org.apache.royale.swc.ISWCFileEntry;
@@ -1037,9 +1039,26 @@ public class MXMLRoyalePublisher extends JSPublisher 
implements IJSRoyalePublish
     {
         StringBuilder depsHTML = new StringBuilder();
 
+        // don't copy scripts/css/assets from a SWC unless we're using at least
+        // one compilation unit from it.
+        // we may have SWCs on the library-path that aren't actually used, and
+        // we don't want to copy anything from those SWCs.
+        Set<ISWC> reachableSWCs = new HashSet<ISWC>();
+        List<ICompilationUnit> reachableUnits = 
project.getReachableCompilationUnitsInSWFOrder(Arrays.asList(project.mainCU));
+        for (ICompilationUnit unit : reachableUnits)
+        {
+            if (!(unit instanceof SWCCompilationUnit))
+            {
+                continue;
+            }
+            SWCCompilationUnit swcUnit = (SWCCompilationUnit) unit;
+            ISWC swc = swcUnit.getSWC();
+            reachableSWCs.add(swc);
+        }
+
         // files included with -js-include-asset are copied to the "assets"
         // sub-directory of the output directory.
-        for (ISWC swc : project.getLibraries())
+        for (ISWC swc : reachableSWCs)
         {
             for (String key : swc.getFiles().keySet())
             {
@@ -1058,7 +1077,7 @@ public class MXMLRoyalePublisher extends JSPublisher 
implements IJSRoyalePublish
 
         // included CSS appears before included JS scripts
         // included CSS from SWC libraries appears before included CSS from 
the app
-        for (ISWC swc : project.getLibraries())
+        for (ISWC swc : reachableSWCs)
         {
             for (String key : swc.getFiles().keySet())
             {
@@ -1088,7 +1107,7 @@ public class MXMLRoyalePublisher extends JSPublisher 
implements IJSRoyalePublish
         // included JS scripts appear after included CSS
         // included JS scripts from SWC libraries appear before included JS
         // scripts from the app
-        for (ISWC swc : project.getLibraries())
+        for (ISWC swc : reachableSWCs)
         {
             for (String key : swc.getFiles().keySet())
             {

Reply via email to