/ / Wie kann ich Scala-Maven-Plugin die Cp1252-Codierung erkennen lassen? - Scala, Maven, Kodierung

Wie kann ich Scala-Maven-Plugin erkennen Cp1252-Codierung? - Scala, Maven, Kodierung

Ich habe mehrere Maven-Module, die Cp1252-Kodierung verwenden. Ich hatte keine Probleme mit dieser Kodierung, bis ich einem der Module scala hinzugefügt habe. Das Scala-Maven-Plugin ignoriert das project.build.sourceEncoding Eigenschaft und versucht, die Quelldateien zu analysieren, als wären sie utf-8.

Ich habe versucht, die Kodierung zur Plugin-Konfiguration hinzuzufügen:

<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>

Wenn das nicht funktionierte, versuchte ich auch, die Kodierung zu den Ausführungen hinzuzufügen:

<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>

Das betreffende Modul hat 1454 Quelldateien, daher ist das Konvertieren des Moduls in utf-8 nicht praktikabel.

Antworten:

1 für die Antwort № 1

Ich habe diese Lösung verwendet:

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

Nicht sicher, ob es für Sie funktioniert.


0 für die Antwort № 2

aus dem doc ist für

Das Argument -encoding für den Java-Compiler. (bei Verwendung eines inkrementellen Compilers).

Es sollte also in Ihrem Fall nicht funktionieren (nicht inkremental + nicht java).

Die Lösung von Gooseman ist die richtige:

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