简体   繁体   中英

Exception during macro expansion with sbt-native-packager and ScalaFXML

I have a small project on github that I created to explore ScalaFx and a few other things I want to use on a bigger project. For now, it includes a single sub-project, which is a simple calculator written using ScalaFX and ScalaFXML.

The project builds and runs fine using the SBT command calculator/run .

I'm now trying to package it using sbt-native-packager. I have added a simplistic project called "exemple-cli" (from sbt-native-packager's documentation), which packages fine with exemple-cli/stage (I get the expected result in exemple-cli/target/universal/stage). However, when I run the command calculator/stage , I get the following error :

> calculator/stage
[info] Main Scala API documentation to /Users/guillaumegaly/IDEAWorkspace/scalafx-trials/calculator/target/scala-2.11/api...
[info] Packaging /Users/guillaumegaly/IDEAWorkspace/scalafx-trials/calculator/target/scala-2.11/calculator_2.11-0.0.1-SNAPSHOT.jar ...
[info] Wrote /Users/guillaumegaly/IDEAWorkspace/scalafx-trials/calculator/target/scala-2.11/calculator_2.11-0.0.1-SNAPSHOT.pom
[info] Done packaging.
Compiling ScalaFXML proxy class for CalculatorController
[error] /Users/guillaumegaly/IDEAWorkspace/scalafx-trials/calculator/src/main/scala/guilgaly/fxtest/calculator/CalculatorController.scala:13: exception during macro expansion: 
[error] java.lang.UnsupportedOperationException: Position.point on NoPosition
[error]     at scala.reflect.internal.util.Position.fail(Position.scala:17)
[error]     at scala.reflect.internal.util.UndefinedPosition.point(Position.scala:95)
[error]     at scala.reflect.internal.util.UndefinedPosition.point(Position.scala:90)
[error]     at scala.reflect.internal.Positions$class.wrappingPos(Positions.scala:42)
[error]     at scala.reflect.internal.SymbolTable.wrappingPos(SymbolTable.scala:16)
[error]     at scala.reflect.internal.Positions$class.wrappingPos(Positions.scala:37)
[error]     at scala.reflect.internal.SymbolTable.wrappingPos(SymbolTable.scala:16)
[error]     at scala.reflect.internal.TreeGen.mkTemplate(TreeGen.scala:378)
[error]     at scala.reflect.internal.ReificationSupport$ReificationSupportImpl$SyntacticClassDef$.apply(ReificationSupport.scala:341)
[error]     at scala.reflect.internal.ReificationSupport$ReificationSupportImpl$SyntacticClassDef$.apply(ReificationSupport.scala:326)
[error]     at scalafxml.core.macros.sfxmlMacro$.impl(sfxmlMacro.scala:162)
[error] @sfxml
[error]  ^
[info] No documentation generated with unsuccessful compiler run
[error] one error found
[error] (calculator/compile:doc) Scaladoc generation failed
[error] Total time: 1 s, completed 29 août 2014 21:39:04

Apparently, there is an error with the macro used by ScalaFXML to generate proxy classes for controllers, but this only occurs when packaging with sbt-native-packager and not when just compiling with SBT... Does anyone have any idea what could cause this?

Looks like SI-8771, which is a regression from 2.11.1 to 2.11.2. The workaround is to either downgrade to 2.11.2 or to change the code of the macro according to the details provided in comments to https://issues.scala-lang.org/browse/SI-8771 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM