scala-maven-plugin does not seem to honor maven sourceEncoding property

269 views
Skip to first unread message

Tony Kay

unread,
Sep 17, 2013, 7:54:21 PM9/17/13
to maven-a...@googlegroups.com
I have a java project that I want to turn into a mixed scala/java project. It has source files encoded with iso-8859-1. My current java pom includes the property:
 
   <project.build.sourceEncoding>iso-8859-1</project.build.sourceEncoding>
 

which allows the project to compile correctly.

When I integrate the scala-maven-plugin, it stops using the maven compiler for Java and uses the zinc compiler to compile the existing java files (I've not even added a scala file yet), and I get errors like this:

[ERROR] error: IO error while decoding /Users/tonykay/swimoffice-scala/MainLib/src/main/java/Util/XmlUtil.java with UTF-8
[INFO] Please try specifying another one using the -encoding option


The usage docs for the plugin say that the default for the "encoding" is whatever is in the project.build.sourceEncoding, but notes that is for incremental mode (which I'm not using).

So, either this is a bug, or I'm not seeing where I can configure this. I tried adding an <encoding>iso-8851-1</encoding> to the <configuration> of the scala-maven-plugin, but that didn't seem to work (not sure I did it right).

Anyone have ideas?

Tony

Martin Grigorov

unread,
Sep 18, 2013, 3:49:32 AM9/18/13
to maven-a...@googlegroups.com
Hi,

Here is how to set the encoding:

 <configuration>
                                                <scalaVersion>${scala.version}</scalaVersion>
                                                <sendJavaToScalac>false</sendJavaToScalac>
                                                <recompileMode>incremental</recompileMode>
                                                <useZincServer>true</useZincServer>
                                                <jvmArgs>
                                                        <jvmArg>-Xmx1024m</jvmArg>
                                                        <jvmArg>-XX:MaxPermSize=256m</jvmArg>
                                                </jvmArgs>
                                                <args>
                                                        <arg>-target:jvm-1.6</arg>
                                                        <arg>-deprecation</arg>
                                                        <arg>-unchecked</arg>
                                                        <arg>-uniqid</arg>
                                                        <arg>-no-specialization</arg>
                                                        <arg>-encoding</arg>
                                                        <arg>UTF-8</arg>                                <!-- HERE -->
                                                        <arg>-feature</arg>

                                                        <!-- prints a message when a method is generated that uses Reflection -->
                                                        <arg>-Xlog-reflective-calls</arg>

                                                        <arg>-Ywarn-adapted-args</arg>
                                                </args>
                                        </configuration>

HTH
Martin


--
 
---
You received this message because you are subscribed to the Google Groups "Maven and Scala" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-and-sca...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

David Bernard

unread,
Sep 18, 2013, 4:42:03 AM9/18/13
to Maven and Scala
Hi,

The usage doc (http://davidb.github.io/scala-maven-plugin/compile-mojo.html#encoding) say it is used for java compiler.
If you thinks it is confusing and should also be used for scala, you can open a ticket https://github.com/davidB/scala-maven-plugin/issues or a Pull request (I agree it is confusing).

Else you can configure the plugin with :

   <arg>-encoding</arg>
   <arg>${project.build.sourceEncoding}</arg>

/davidB
Reply all
Reply to author
Forward
0 new messages