royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yishay Weiss <yishayj...@hotmail.com>
Subject RE: [royale-compiler] branch develop updated: handle main MXML file in packages
Date Mon, 19 Mar 2018 07:52:20 GMT
I’m still getting an error when compiling our app using the up2date compiler.



   [mxmlc] Internal error: java.lang.NullPointerException: Source must not be null org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:1362)org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:1310)org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyalePublisher.publish(MXMLRoyalePublisher.java:206)org.apache.royale.compiler.clients.MXMLJSCRoyale.compile(MXMLJSCRoyale.java:384)org.apache.royale.compiler.clients.MXMLJSCRoyale._mainNoExit(MXMLJSCRoyale.java:240)org.apache.royale.compiler.clients.MXMLJSCRoyale.mainNoExit(MXMLJSCRoyale.java:197)org.apache.royale.compiler.clients.MXMLJSC._mainNoExit(MXMLJSC.java:345)org.apache.royale.compiler.clients.MXMLJSC.mainNoExit(MXMLJSC.java:281)org.apache.royale.compiler.clients.MXMLJSC.staticMainNoExit(MXMLJSC.java:240)org.apache.royale.compiler.clients.MXMLJSC.main(MXMLJSC.java:222)



________________________________
From: Alex Harui <aharui@adobe.com.INVALID>
Sent: Monday, March 19, 2018 2:40:38 AM
To: dev@royale.apache.org
Subject: Re: [royale-compiler] branch develop updated: handle main MXML file in packages

I took care of it.

On 3/18/18, 1:16 AM, "Harbs" <harbs.lists@gmail.com> wrote:

>This commit appears to break things.
>
>I’m getting the following error in Core tests:
>
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpaste.apa
>che.org%2FBmsg&data=02%7C01%7Caharui%40adobe.com%7C41c93109f528477fe9bb08d
>58ca8983b%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636569578094796225&
>sdata=fanlDrBFFOSL0rpZNNR7IMZyFOxmeJeR5riVdFJcLH8%3D&reserved=0
><https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpaste.ap
>ache.org%2FBmsg&data=02%7C01%7Caharui%40adobe.com%7C41c93109f528477fe9bb08
>d58ca8983b%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636569578094796225
>&sdata=fanlDrBFFOSL0rpZNNR7IMZyFOxmeJeR5riVdFJcLH8%3D&reserved=0>
>
>Harbs
>
>> On Mar 17, 2018, at 5:16 PM, aharui@apache.org wrote:
>>
>> This is an automated email from the ASF dual-hosted git repository.
>>
>> aharui pushed a commit to branch develop
>> in repository
>>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitbox.a
>>pache.org%2Frepos%2Fasf%2Froyale-compiler.git&data=02%7C01%7Caharui%40ado
>>be.com%7C41c93109f528477fe9bb08d58ca8983b%7Cfa7b1b5a7b34438794aed2c178dec
>>ee1%7C0%7C0%7C636569578094796225&sdata=hx1FTlGgdcEVSsfSfHW0gAVPVvFwwmJdeu
>>iIQQx2QtY%3D&reserved=0
>>
>>
>> The following commit(s) were added to refs/heads/develop by this push:
>>     new ac500b7  handle main MXML file in packages
>> ac500b7 is described below
>>
>> commit ac500b75530fc9094768824e4339fbd7df95e7ed
>> Author: Alex Harui <aharui@apache.org>
>> AuthorDate: Sat Mar 17 08:16:12 2018 -0700
>>
>>    handle main MXML file in packages
>> ---
>> .../internal/codegen/js/jsc/JSCPublisher.java      | 10 ++--
>> .../internal/codegen/js/node/NodePublisher.java    | 14 ++---
>> .../codegen/mxml/royale/MXMLRoyalePublisher.java   | 61
>>++++++++++++++--------
>> .../compiler/internal/graph/GoogDepsWriter.java    |  4 --
>> .../internal/projects/SourceListManager.java       |  4 +-
>> .../internal/projects/SourcePathManager.java       | 11 ++++
>> 6 files changed, 64 insertions(+), 40 deletions(-)
>>
>> diff --git
>>a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/j
>>s/jsc/JSCPublisher.java
>>b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/j
>>s/jsc/JSCPublisher.java
>> index 8f530e2..4a54cfb 100644
>> ---
>>a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/j
>>s/jsc/JSCPublisher.java
>> +++
>>b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/j
>>s/jsc/JSCPublisher.java
>> @@ -41,28 +41,28 @@ public class JSCPublisher extends
>>MXMLRoyalePublisher
>>     private RoyaleJSProject project;
>>
>>     @Override
>> -    protected String getTemplateBody(String projectName)
>> +    protected String getTemplateBody(String mainClassQName)
>>     {
>> -        IDefinition def =
>>project.resolveQNameToDefinition(projectName);
>> +        IDefinition def =
>>project.resolveQNameToDefinition(mainClassQName);
>>         IDefinitionNode node = def.getNode();
>>         if (node instanceof IMXMLDocumentNode)
>>         {
>>             //we should probably customize MXML too, but for now, pass
>>it to the
>>             //default implementation -JT
>> -            return super.getTemplateBody(projectName);
>> +            return super.getTemplateBody(mainClassQName);
>>         }
>>         //for ActionScript classes, simply call the constructor by
>>default
>>         StringBuilder bodyHTML = new StringBuilder();
>>         bodyHTML.append("\t<script type=\"text/javascript\">\n");
>>         bodyHTML.append("\t\tnew ");
>> -        bodyHTML.append(projectName);
>> +        bodyHTML.append(mainClassQName);
>>         bodyHTML.append("();\n");
>>         bodyHTML.append("\t</script>\n");
>>         return bodyHTML.toString();
>>     }
>>
>>     @Override
>> -    protected void writeHTML(String type, String projectName, File
>>targetDir,
>> +    protected void writeHTML(String type, String projectName, String
>>mainClassQName, File targetDir,
>>                              String deps, List<String> additionalHTML)
>>throws IOException
>>     {
>>         if ("intermediate".equals(type))
>> diff --git
>>a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/j
>>s/node/NodePublisher.java
>>b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/j
>>s/node/NodePublisher.java
>> index bb3515d..3c2eb6f 100644
>> ---
>>a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/j
>>s/node/NodePublisher.java
>> +++
>>b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/j
>>s/node/NodePublisher.java
>> @@ -37,7 +37,7 @@ public class NodePublisher extends JSCPublisher
>>     }
>>
>>     @Override
>> -    protected String getTemplateDependencies(String type, String
>>projectName, String deps)
>> +    protected String getTemplateDependencies(String type, String
>>projectName, String mainClassQName, String deps)
>>     {
>>         StringBuilder depsJS = new StringBuilder();
>>         if ("intermediate".equals(type))
>> @@ -62,31 +62,31 @@ public class NodePublisher extends JSCPublisher
>>     }
>>
>>     @Override
>> -    protected String getTemplateBody(String projectName)
>> +    protected String getTemplateBody(String mainClassQName)
>>     {
>>         StringBuilder bodyJS = new StringBuilder();
>>         if (exportModule)
>>         {
>>             bodyJS.append("module.exports = ");
>> -            bodyJS.append(projectName);
>> +            bodyJS.append(mainClassQName);
>>             bodyJS.append(";");
>>         }
>>         else
>>         {
>>             bodyJS.append("new ");
>> -            bodyJS.append(projectName);
>> +            bodyJS.append(mainClassQName);
>>             bodyJS.append("();");
>>         }
>>         return bodyJS.toString();
>>     }
>>
>>     @Override
>> -    protected void writeHTML(String type, String projectName, File
>>targetDir,
>> +    protected void writeHTML(String type, String projectName, String
>>mainClassQName, File targetDir,
>>                              String deps, List<String> additionalHTML)
>>throws IOException
>>     {
>>         StringBuilder contents = new StringBuilder();
>> -        contents.append(getTemplateDependencies(type, projectName,
>>deps));
>> -        contents.append(getTemplateBody(projectName));
>> +        contents.append(getTemplateDependencies(type, projectName,
>>mainClassQName, deps));
>> +        contents.append(getTemplateBody(mainClassQName));
>>         writeFile(new File(targetDir, "index.js"), contents.toString(),
>>false);
>>     }
>> }
>> diff --git
>>a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/m
>>xml/royale/MXMLRoyalePublisher.java
>>b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/m
>>xml/royale/MXMLRoyalePublisher.java
>> index 1c3e943..6ad8bbb 100644
>> ---
>>a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/m
>>xml/royale/MXMLRoyalePublisher.java
>> +++
>>b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/m
>>xml/royale/MXMLRoyalePublisher.java
>> @@ -96,11 +96,11 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>     private boolean useStrictPublishing;
>>
>>     private GoogDepsWriter getGoogDepsWriter(File intermediateDir,
>> -                                                                             String
projectName,
>> +                                                                             String
mainClassQName,
>>                                                                               JSGoogConfiguration
googConfiguration,
>>                                                                               List<ISWC>
swcs)
>>     {
>> -     return new GoogDepsWriter(intermediateDir, projectName,
>>googConfiguration, swcs);
>> +     return new GoogDepsWriter(intermediateDir, mainClassQName,
>>googConfiguration, swcs);
>>     }
>>
>>     @Override
>> @@ -159,7 +159,25 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>         // The "intermediate" is the "js-debug" output.
>>         final File intermediateDir = outputFolder;
>>
>> +        // The source directory is the source path entry containing
>>the Main class.
>> +        List<File> sourcePaths = project.getSourcePath();
>> +        String targetFile =
>>configuration.getTargetFile().toLowerCase();
>> +        File imageSrcDir = null;
>> +        for (File sp : sourcePaths)
>> +        {
>> +             String lowercasePath = sp.getAbsolutePath().toLowerCase();
>> +             if (targetFile.startsWith(lowercasePath))
>> +                     imageSrcDir = sp;
>> +        }
>>         final String projectName =
>>FilenameUtils.getBaseName(configuration.getTargetFile());
>> +        String qName = null;
>> +        try {
>> +                    qName = project.mainCU.getQualifiedNames().get(0);
>> +            } catch (InterruptedException e) {
>> +                    // TODO Auto-generated catch block
>> +                    e.printStackTrace();
>> +            }
>> +            final String mainClassQName = qName;
>>         final String outputFileName = projectName + "." +
>>project.getBackend().getOutputExtension();
>>
>>         // The "release" is the "js-release" directory.
>> @@ -184,11 +202,8 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>         IOFileFilter assetFiles = FileFilterUtils.or(pngSuffixFilter,
>>jpgSuffixFilter, jpegSuffixFilter, svgSuffixFilter, gifSuffixFilter,
>>                 jsonSuffixFilter);
>>         IOFileFilter resourceFilter =
>>FileFilterUtils.or(DirectoryFileFilter.DIRECTORY, assetFiles);
>> -        // The source directory is the directory containing the Main
>>class.
>> -        File imageSrcDir = new
>>File(configuration.getTargetFile()).getAbsoluteFile().getParentFile();
>>         // FIXME: All images need to be located relative to the Main
>>class ... for Maven this is a problem.
>>         FileUtils.copyDirectory(imageSrcDir, intermediateDir,
>>resourceFilter);
>> -
>>         // Iterate over all themes SWCs and add the contents of any
>>included files in
>>         // an assets folder to an assets folder in the destination
>>folder.
>>         final ISWCManager swcManager =
>>project.getWorkspace().getSWCManager();
>> @@ -347,7 +362,7 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>         // Add all files generated by the compiler to the compilation
>>unit.
>>
>>/////////////////////////////////////////////////////////////////////////
>>////////
>>
>> -        GoogDepsWriter gdw = getGoogDepsWriter(intermediateDir,
>>projectName, googConfiguration, allswcs);
>> +        GoogDepsWriter gdw = getGoogDepsWriter(intermediateDir,
>>mainClassQName, googConfiguration, allswcs);
>>         // This list contains all files generated by the compiler, this
>>is both the
>>         // compiled js files created by the sources of the current
>>project plus the
>>         // js files of used dependencies.
>> @@ -365,10 +380,10 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>         // is generated here so it can be used for outputting the html
>>templates.
>>         String depsFileData = gdw.generateDeps(project, problems);
>>
>> -        if (project.isModule(projectName))
>> +        if (project.isModule(mainClassQName))
>>         {
>>               // need better test someday
>> -             depsFileData += "\ngoog.require('" + projectName + "');\n";
>> +             depsFileData += "\ngoog.require('" + mainClassQName + "');\n";
>>             writeFile(new File(intermediateDir, projectName +
>>"__deps.js"), depsFileData, false);
>>             Set<String> provideds = computeProvideds(depsFileData);
>>             compilerWrapper.setProvideds(provideds);
>> @@ -380,17 +395,17 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>               // Create the index.html for the debug-js version.
>>               if (!((JSGoogConfiguration)configuration).getSkipTranspile()) {
>>                   if (template != null) {
>> -                    writeTemplate(template, "intermediate", projectName,
>>intermediateDir, depsFileData, gdw.additionalHTML);
>> +                    writeTemplate(template, "intermediate", projectName,
>>mainClassQName, intermediateDir, depsFileData, gdw.additionalHTML);
>>                   } else {
>> -                    writeHTML("intermediate", projectName,
>>intermediateDir, depsFileData, gdw.additionalHTML);
>> +                    writeHTML("intermediate", projectName,
>>mainClassQName, intermediateDir, depsFileData, gdw.additionalHTML);
>>                   }
>>               }
>>               // Create the index.html for the release-js version.
>>               if (configuration.release()) {
>>                   if (template != null) {
>> -                    writeTemplate(template, "release", projectName,
>>releaseDir, depsFileData, gdw.additionalHTML);
>> +                    writeTemplate(template, "release", projectName,
>>mainClassQName, releaseDir, depsFileData, gdw.additionalHTML);
>>                   } else {
>> -                    writeHTML("release", projectName, releaseDir, null,
>>gdw.additionalHTML);
>> +                    writeHTML("release", projectName, mainClassQName,
>>releaseDir, null, gdw.additionalHTML);
>>                   }
>>               }
>>         }
>> @@ -608,7 +623,7 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>         return code;
>>     }
>>
>> -    protected void writeTemplate(File template, String type, String
>>projectName, File targetDir, String deps, List<String> additionalHTML)
>> +    protected void writeTemplate(File template, String type, String
>>projectName, String mainClassQName, File targetDir, String deps,
>>List<String> additionalHTML)
>>               throws IOException
>>       {
>>           // Check if the template exists.
>> @@ -629,7 +644,7 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>             bgcolor = ta.getBackgroundColor();
>>             pageTitle = ta.getPageTitle();
>>         }
>> -        String result = input.replaceAll("\\$\\{application\\}",
>>projectName);
>> +        String result = input.replaceAll("\\$\\{application\\}",
>>mainClassQName);
>>         if (bgcolor != null)
>>             result = result.replaceAll("\\$\\{bgcolor\\}", bgcolor);
>>         //result = result.replaceAll("\\$\\{expressInstallSwf\\}",
>>expressInstallSwf);
>> @@ -646,10 +661,10 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>
>>         StringBuilder addHTML = new StringBuilder();
>>         addHTML.append(getTemplateAdditionalHTML(additionalHTML));
>> -            addHTML.append(getTemplateDependencies(type, projectName, deps));
>> +            addHTML.append(getTemplateDependencies(type, projectName,
>>mainClassQName, deps));
>>         result = result.replaceAll("\\$\\{head\\}", addHTML.toString());
>>
>> -        String templateBody = getTemplateBody(projectName);
>> +        String templateBody = getTemplateBody("release".equals(type) ?
>>projectName : mainClassQName);
>>         result = result.replaceAll("\\$\\{body\\}", templateBody);
>>
>>               writeFile(new File(targetDir,
>>googConfiguration.getHtmlOutputFileName()), result, false);
>> @@ -665,7 +680,7 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>         return htmlFile.toString();
>>     }
>>
>> -    protected String getTemplateDependencies(String type, String
>>projectName, String deps)
>> +    protected String getTemplateDependencies(String type, String
>>projectName, String mainClassQName, String deps)
>>     {
>>         StringBuilder depsHTML = new StringBuilder();
>>         if ("intermediate".equals(type))
>> @@ -674,7 +689,7 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>             depsHTML.append("\t<script type=\"text/javascript\">\n");
>>             depsHTML.append(deps);
>>             depsHTML.append("\t\tgoog.require(\"");
>> -            depsHTML.append(projectName);
>> +            depsHTML.append(mainClassQName);
>>             depsHTML.append("\");\n");
>>             depsHTML.append("\t</script>\n");
>>         }
>> @@ -687,19 +702,19 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>         return depsHTML.toString();
>>     }
>>
>> -    protected String getTemplateBody(String projectName)
>> +    protected String getTemplateBody(String mainClassQName)
>>     {
>>         StringBuilder bodyHTML = new StringBuilder();
>>         bodyHTML.append("\t<script type=\"text/javascript\">\n");
>>         bodyHTML.append("\t\tnew ");
>> -        bodyHTML.append(projectName);
>> +        bodyHTML.append(mainClassQName);
>>         bodyHTML.append("()");
>>         bodyHTML.append(".start();\n");
>>         bodyHTML.append("\t</script>\n");
>>         return bodyHTML.toString();
>>     }
>>
>> -    protected void writeHTML(String type, String projectName, File
>>targetDir, String deps, List<String> additionalHTML)
>> +    protected void writeHTML(String type, String projectName, String
>>mainClassQName, File targetDir, String deps, List<String> additionalHTML)
>>             throws IOException
>>     {
>>         StringBuilder htmlFile = new StringBuilder();
>> @@ -711,12 +726,12 @@ public class MXMLRoyalePublisher extends
>>JSGoogPublisher implements IJSPublisher
>>         htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\"
>>href=\"").append(projectName).append(".css\">\n");
>>
>>         htmlFile.append(getTemplateAdditionalHTML(additionalHTML));
>> -        htmlFile.append(getTemplateDependencies(type, projectName,
>>deps));
>> +        htmlFile.append(getTemplateDependencies(type, projectName,
>>mainClassQName, deps));
>>
>>         htmlFile.append("</head>\n");
>>         htmlFile.append("<body>\n");
>>
>> -        htmlFile.append(getTemplateBody(projectName));
>> +        htmlFile.append(getTemplateBody(mainClassQName));
>>
>>         htmlFile.append("</body>\n");
>>         htmlFile.append("</html>");
>> diff --git
>>a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/Goo
>>gDepsWriter.java
>>b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/Goo
>>gDepsWriter.java
>> index b412817..45f95b6 100644
>> ---
>>a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/Goo
>>gDepsWriter.java
>> +++
>>b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/graph/Goo
>>gDepsWriter.java
>> @@ -703,10 +703,6 @@ public class GoogDepsWriter {
>>           File f;
>>
>>               String classPath = className.replace(".", File.separator);
>> -            // special case app names with underscores, but hope that
>> -            // no other class names have underscores in them
>> -        if (className.equals(mainName))
>> -             classPath = className;
>>
>>         fn = outputFolderPath + File.separator + classPath + ".js";
>>         f = new File(fn);
>> diff --git
>>a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/Sou
>>rceListManager.java
>>b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/Sou
>>rceListManager.java
>> index 21bd8a4..a42555a 100644
>> ---
>>a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/Sou
>>rceListManager.java
>> +++
>>b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/Sou
>>rceListManager.java
>> @@ -124,8 +124,10 @@ final class SourceListManager
>>             unitsToAdd = new
>>ArrayList<ICompilationUnit>(newSourcesToCreate.size());
>>             for (File file : newSourcesToCreate)
>>             {
>> +             File sourcePath = sourcePathManager.getSourcePath(file);
>> +             String qname = sourcePathManager.computeQName(sourcePath,
>>file);
>>                 ICompilationUnit unit =
>>project.getSourceCompilationUnitFactory().createCompilationUnit(
>> -                    file, DefinitionPriority.BasePriority.SOURCE_LIST,
>>0, null, null);
>> +                    file, DefinitionPriority.BasePriority.SOURCE_LIST,
>>0, qname, null);
>>
>>                 //It can be null in some cases, see
>>#ResourceBundleSourceFileHandler
>>                 if(unit != null)
>> diff --git
>>a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/Sou
>>rcePathManager.java
>>b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/Sou
>>rcePathManager.java
>> index 23f8bbc..366cab1 100644
>> ---
>>a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/Sou
>>rcePathManager.java
>> +++
>>b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/Sou
>>rcePathManager.java
>> @@ -95,6 +95,17 @@ public final class SourcePathManager
>>         return false;
>>     }
>>
>> +    public File getSourcePath(File file)
>> +    {
>> +        for (final DirectoryID directory : sourcePaths.keySet())
>> +        {
>> +            if (directory.isParentOf(file))
>> +                return directory.getFile();
>> +        }
>> +
>> +        return null;
>> +    }
>> +
>>     private void accumulateQNameFiles(Set<QNameFile> qNameFiles, File
>>directory, String baseQName, String locale,
>>             Collection<ICompilerProblem> problems, int order)
>>     {
>>
>> --
>> To stop receiving notification emails like this one, please contact
>> aharui@apache.org.
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message