playframework - Scala Play 2.0. Compilation error: IO error while decoding -
i downloaded multi-module scala project github (https://github.com/henrikengstrom/roygbiv), , 1 of module play 2.0 module. can run whole application using sbt's run
command on each module, , works fine. when add play 2.0 template (index.scala.html
) non-english characters , press f5 in browser compilation error:
io error while decoding c:\users...\web\target\scala-2.9.1\src_managed\main\views\html\index.template.scala utf-8 please try specifying 1 using -encoding option
play 2.0 module run using sbt's run
command, not using play
console.
i checked source file encoding - utf-8. tried utf-8 without bom.
where can problem?
your problem seems this: intermediate scala files not encoded correctly.
here process:
play takes template file (foo.scala.html
) , translates scala: target/scala-2.10/src_managed/main/views/html/foo.template.scala
. gets compiled sbt .class files , run play.
when sbt creates these intermediate files, creates them default encoding (in case windows machine utf-8 without bom - machine may differ). importantly, encoding sticks around, if change encoding of original template file (foo.scala.html utf-16), encoding of .scala file still same (utf-8 without bom in case). however, file no longer compiles because file can't read because scala compiler expecting itf-8.
the 'correct' solution use utf-8, , in fact solution recommended play 1.x see play documentation internationalization. here equivalent play 2. can use normal internationalization messages files.
so, if specify
java_tool_options='-dfile.encoding=utf8' sbt
as suggested bjorn, tell sbt files reads , writes in utf8. can specify file encoding scala compiler in build.scala:
val main = play.project(appname, appversion, appdependencies).settings( scalacoptions ++= seq("-encoding", "utf-8") // add own project settings here )
this tells scala compiler files reads (i.e. foo.template.scala) encoded in utf-8. if set default encoding, may work well.
your best bet sbt clean, ensuring offending files have disappeared, , restarting java_tool_option suggested above. however, you'll have ensure of builds take account (jenkins, other developers etc).
Comments
Post a Comment