Liferay 6.2 Ant Build-升级SCSS编译器

时间:2019-04-15 03:12:22

标签: eclipse sass ant liferay liferay-theme

我目前正在开发liferay主题,但是在编译一个SCSS文件时,出现以下错误:

 [java] Sass::SyntaxError: Invalid CSS after "  @each $key": expected "in", was ", $num in $map {"
 [java]            expected at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:1147
 [java]            expected at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:1084
 [java]                tok! at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:1079
 [java]      each_directive at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:248
 [java]                send at org/jruby/RubyKernel.java:2093
 [java]   special_directive at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:174
 [java]           directive at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:146
 [java]         block_child at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:553
 [java]      block_contents at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:545
 [java]               block at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:534
 [java]     mixin_directive at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:186
 [java]                send at org/jruby/RubyKernel.java:2093
 [java]   special_directive at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:174
 [java]           directive at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:146
 [java]         block_child at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:552
 [java]      block_contents at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:542
 [java]          stylesheet at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:82
 [java]               parse at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/scss/parser.rb:27
 [java]            _to_tree at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/engine.rb:342
 [java]             to_tree at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/engine.rb:272
 [java]        visit_import at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:225
 [java]                send at org/jruby/RubyKernel.java:2097
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/base.rb:37
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:100
 [java]        visit_import at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:227
 [java]             collect at org/jruby/RubyArray.java:2318
 [java]        visit_import at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:227
 [java]                send at org/jruby/RubyKernel.java:2097
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/base.rb:37
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:100
 [java]      visit_children at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/base.rb:53
 [java]             collect at org/jruby/RubyArray.java:2318
 [java]      visit_children at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/base.rb:53
 [java]      visit_children at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:109
 [java]    with_environment at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:121
 [java]      visit_children at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:108
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/base.rb:37
 [java]          visit_rule at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:320
 [java]                send at org/jruby/RubyKernel.java:2097
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/base.rb:37
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:100
 [java]      visit_children at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/base.rb:53
 [java]             collect at org/jruby/RubyArray.java:2318
 [java]      visit_children at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/base.rb:53
 [java]      visit_children at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:109
 [java]    with_environment at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:121
 [java]      visit_children at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:108
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/base.rb:37
 [java]          visit_root at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:128
 [java]                send at org/jruby/RubyKernel.java:2097
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/base.rb:37
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:100
 [java]                send at org/jruby/RubyKernel.java:2097
 [java]               visit at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/visitors/perform.rb:7
 [java]              render at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/tree/root_node.rb:20
 [java]             _render at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/engine.rb:315
 [java]              render at C:/Users/BARRYC~1/AppData/Local/Temp/liferay/ruby/gems/sass-3.2.12/lib/sass/../sass/engine.rb:262
 [java]              (root) at <script>:48
 [java] Exception in thread "main" org.jruby.embed.EvalFailedException: (SyntaxError) Invalid CSS after "  @each $key": expected "in", was ", $num in $map {"
 [java]     at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:127)
 [java]     at org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1231)
 [java]     at org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1224)
 [java]     at com.liferay.portal.scripting.ruby.RubyExecutor.doEval(RubyExecutor.java:189)
 [java]     at com.liferay.portal.scripting.ruby.RubyExecutor.eval(RubyExecutor.java:229)
 [java]     at com.liferay.portal.scripting.ruby.RubyExecutor.eval(RubyExecutor.java:129)
 [java]     at com.liferay.portal.tools.SassToCssBuilder._parseSassFile(SassToCssBuilder.java:288)
 [java]     at com.liferay.portal.tools.SassToCssBuilder._parseSassDirectory(SassToCssBuilder.java:247)
 [java]     at com.liferay.portal.tools.SassToCssBuilder.<init>(SassToCssBuilder.java:139)
 [java]     at com.liferay.portal.tools.SassToCssBuilder.main(SassToCssBuilder.java:93)
 [java] Caused by: org.jruby.exceptions.RaiseException: (SyntaxError) Invalid CSS after "  @each $key": expected "in", was ", $num in $map {"
 [java] Unable to parse /css/aui.css
 [java] Java Result: 1

有问题的文件(aui.css):

$FontAwesomePath: "aui/font-awesome-5/font" !default;

//@import "aui/alloy-font-awesome/scss/variables";
//@import "aui/alloy-font-awesome/scss/mixins-alloy";
//@import "aui/alloy-font-awesome/scss/path-alloy";

.aui {
    @import "aui_variables";

    $iconSpritePath: '../images/aui/glyphicons-halflings.png' !default;
    $iconWhiteSpritePath: '../images/aui/glyphicons-halflings-white.png' !default;

    //@import "aui/bootstrap"; // Remove >> Bootstrap 2.3.2
    @import "aui/variables-alloy";
    @import "aui/variables";
    @import "aui/bs4/bootstrap"; // Add >> Bootstrap 3.5
}

我正在使用Liferay 6.2 EE GA1,而我读到的该错误可能可以通过升级SCSS编译器(红宝石)来解决。但是,我不知道该如何处理。它正在使用ant构建器(build.xml)。

如果我可以修复以上错误,或者升级编译器(或同时升级两者),那就太好了!

2 个答案:

答案 0 :(得分:1)

如果要手动升级SASS版本,可以重新设置scripting.jruby.load.paths属性。请查看6.2 Portal Properties。因此,您不是在使用classpath或java.io.tmpdir,而是在使用其他文件夹。但是,我没有对此进行测试,并且此升级可能会导致其他操作失败(也需要有关CI构建的概念)。

答案 1 :(得分:1)

我设法将Liferay 6.2升级到引导程序4:

  1. 您需要转到tomcat / webapps / ROOT / WEB-INF / lib并删除 ruby​​-gems.jar

  2. 下载 com.liferay.ruby.gems-1.0.1.jar (在线搜索)并将其放在上方的lib文件夹中

  3. 修改您的portal-ext.properties并添加以下内容:

#jruby fix
scripting.jruby.load.paths=\
classpath:/META-INF/jruby.home/lib/ruby/site_ruby/1.8,\
classpath:/META-INF/jruby.home/lib/ruby/site_ruby/shared,\
classpath:/gems/chunky_png-1.3.5/lib,\
classpath:/gems/compass-1.0.1/lib,\
classpath:/gems/compass-core-1.0.3/lib,\
classpath:/gems/multi_json-1.11.3/lib,\
classpath:/gems/fssm-0.2.9/lib,\
classpath:/gems/sass-3.4.22/lib,\
${java.io.tmpdir}/liferay/ruby/gems/chunky_png-1.3.5/lib,\
${java.io.tmpdir}/liferay/ruby/gems/compass-1.0.1/lib,\
${java.io.tmpdir}/liferay/ruby/gems/fssm-0.2.9/lib,\
${java.io.tmpdir}/liferay/ruby/gems/sass-3.4.22/lib
  1. 清理tomcat的工作和临时目录,然后重新启动Liferay

我也改变了我的主题..将所有aui.css,main.css(和导入)文件更改为scss文件(因为它们不是真正的CSS),并使用webpack 4对其进行了编译(速度更快)比Ruby)。