How can I make scala-maven-plugin recognize Cp1252 encoding?
I have several maven modules that use Cp1252 encoding. I had no problem with this coding until I added scala to one of the modules. The scala -maven plugin ignores the property project.build.sourceEncoding
and tries to parse the source files as if they were UTF-8.
I tried adding encoding to the plugin config:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.6</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<encoding>Cp1252</encoding>
</configuration>
</plugin>
If that didn't work, I also tried adding the encoding to the execution:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.6</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
<configuration>
<sourceDir>${basedir}/scala</sourceDir>
<encoding>Cp1252</encoding>
</configuration>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<sourceDir>${basedir}/scala</sourceDir>
<encoding>Cp1252</encoding>
</configuration>
</execution>
</executions>
<configuration>
<encoding>Cp1252</encoding>
</configuration>
</plugin>
The module in question has 1,454 source files, so converting the module to use UTF-8 is impractical.
+3
source to share
2 answers
from document for
The -encoding argument to the Java compiler. (when using an incremental compiler).
So it shouldn't work in your case (not incremental + not java).
Gooseman's solution is correct:
<configuration>
<args>
<arg>-encoding</arg>
<arg>${project.build.sourceEncoding}</arg>
</args>
</configuration>
0
source to share