compileAssets failing on upgrading Grails application

孤者浪人 提交于 2021-02-11 14:46:20

问题


I have a Grails application running version 3.3. I recently upgraded to version 4.0.3. The way I typically upgrade, which I understand is probably not the best way, is to upgrade my environment to the new Grails version, then create a brand new Grails project (I'm using IntelliJ), and then slowly move my files over from the old project to the new project, fixing things as I find they don't work. I have everything moved over and the app works perfectly while running run-app inside IntelliJ. However, if I go to the terminal and run "grails war" I get all kinds of issues compiling assets. I don't typically pay much attention to how assets are handled (this is just a personal application). I see that in my build.gradle file it's using asset pipeline plugin version 3.0.10 (com.bertramlabs.plugins:asset-pipeline-gradle:3.0.10). If I change these references back to the assetPipeline version that was being used in my Grails 3 app (2.14.2), then the errors go away. Does anyone know if there is a difference in these versions that could be causing my issue?

Here's a big chunk of the error stack:

...
Processing File 138 of 140 - redmond/images/ui-icons_cd0a0a_256x240.png
Processing File 139 of 140 - redmond/images/ui-icons_d8e7f3_256x240.png
Processing File 140 of 140 - redmond/images/ui-icons_f9bd01_256x240.png
> Task :Wolf:assetCompile FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1/userguide/command_line_interface.html#sec:command_line_warnings
1 actionable task: 1 executed
<-------------> 0% WAITING
> Deleting unused version-specific caches in E:\java_dev\projects\Wolf4\.gradle
effects.unminified.js:720: ERROR - Object literal contains illegal duplicate key "scaleMode", disallowed in strict mode
    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
    ^^^^^^^^^

Closure uglify JS Exception
asset.pipeline.processors.MinifyException: [Lcom.google.javascript.jscomp.JSError;@3ad6a23
        at asset.pipeline.processors.ClosureCompilerProcessor.process(ClosureCompilerProcessor.groovy:80)
        at asset.pipeline.processors.ClosureCompilerProcessor$process$0.call(Unknown Source)
        at asset.pipeline.AssetCompiler$_compile_closure4.doCall(AssetCompiler.groovy:173)
        at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
        at groovy.lang.Closure.call(Closure.java:405)
        at groovy.lang.Closure.call(Closure.java:399)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
rico.unminified.js:163: ERROR - Object literal contains illegal duplicate key "hoverTextColor", disallowed in strict mode
         hoverTextColor      : '#ffffff',
         ^^^^^^^^^^^^^^

Closure uglify JS Exception
asset.pipeline.processors.MinifyException: [Lcom.google.javascript.jscomp.JSError;@7bb4d5d3
        at asset.pipeline.processors.ClosureCompilerProcessor.process(ClosureCompilerProcessor.groovy:80)
        at asset.pipeline.processors.ClosureCompilerProcessor$process$0.call(Unknown Source)
        at asset.pipeline.AssetCompiler$_compile_closure4.doCall(AssetCompiler.groovy:173)
        at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
        at groovy.lang.Closure.call(Closure.java:405)
        at groovy.lang.Closure.call(Closure.java:399)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
unittest.unminified.js:457: ERROR - Object literal contains illegal duplicate key "benchmark", disallowed in strict mode
  benchmark: function(operation, iterations) {
  ^^^^^^^^^

Closure uglify JS Exception
asset.pipeline.processors.MinifyException: [Lcom.google.javascript.jscomp.JSError;@3e732fc9
        at asset.pipeline.processors.ClosureCompilerProcessor.process(ClosureCompilerProcessor.groovy:80)
        at asset.pipeline.processors.ClosureCompilerProcessor$process$0.call(Unknown Source)
        at asset.pipeline.AssetCompiler$_compile_closure4.doCall(AssetCompiler.groovy:173)
        at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)

回答1:


One of the things I noticed the times I have attempted to upgrade my projects is that while Grails 4 was released, they didn't upgrade (or test) ALOT of the plugins; in fact they are still playing catchup with all the plugins.

If you can get your project to work with the old plugin, I say do it. Otherwise wait on your upgrade tile the plugins are better tested... and submit your bug.




回答2:


I have reverted back to the previous version of the assetPipeline plugin and that allows me to compile without error.

But for anyone else that comes across this, I noticed that after upgrading Grails I was having issues with the war version of my application once it was deployed to Tomcat.

First issue -

war {
   archiveName "Wolf.war"
}

No longer named my war file as desired. I asked about this in a different question and the first answer was to use bootWar instead of war, such as:

bootWar {
   archiveName "Wolf.war"
}

This did indeed name the war file correctly. However, now when the war file was dropped into tomcat, and tomcat exploded it, it included an org.springframework.boot.loader folder inside the webapp which I didn't previously have. This doesn't seem right. In addition, I no longer had the assets directory, so all of my custom js, css, and images were missing from the deployed app. After much googling, I found something that suggested doing this:

war {
    enabled = true
    archiveName "Wolf.war"
}

This resolved all my issues. My war file is named correctly, the war file contains the assets, and the war file does not contain the boot folder. And, the deployed app works correctly. So, I don't know if this is the "proper" way that I should be doing it, but it works.



来源:https://stackoverflow.com/questions/61934349/compileassets-failing-on-upgrading-grails-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!