From d30f56b2c9887ca83b839a5a9c3dc0ee5b3e6df5 Mon Sep 17 00:00:00 2001 From: Jan Sievers Date: Fri, 20 Apr 2012 17:26:42 +0200 Subject: [PATCH] 373759 compiler should honor project.build.sourceEncoding Same as maven-compiler-plugin[1], tycho-compiler-plugin now supports ${project.build.sourceEncoding} for configuring the java source file encoding. Legacy ${maven.compiler.encoding} is kept but deprecated and @readonly, so invisible for maven site documentation. ${project.build.sourceEncoding} has precedence if both are present. [1] https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#encoding Change-Id: Iad86c1b10761658c075562d509b392081323475f --- .../maven/plugin/AbstractCompilerMojo.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tycho-compiler-plugin/src/main/java/copied/org/apache/maven/plugin/AbstractCompilerMojo.java b/tycho-compiler-plugin/src/main/java/copied/org/apache/maven/plugin/AbstractCompilerMojo.java index ce18b39795..a27acdc12b 100644 --- a/tycho-compiler-plugin/src/main/java/copied/org/apache/maven/plugin/AbstractCompilerMojo.java +++ b/tycho-compiler-plugin/src/main/java/copied/org/apache/maven/plugin/AbstractCompilerMojo.java @@ -114,11 +114,20 @@ public abstract class AbstractCompilerMojo extends AbstractMojo { protected String target; /** - * The -encoding argument for the Java compiler + * The -encoding argument for the Java compiler (kept for backwards compatibility) * * @parameter expression="${maven.compiler.encoding}" + * @readonly + * @deprecated use {@link #encoding} */ - private String encoding; + private String mavenCompilerEncoding; + + /** + * The -encoding argument for the Java compiler + * + * @parameter expression="${project.build.sourceEncoding}" + */ + private String encoding; /** * The granularity in milliseconds of the last modification date for testing @@ -441,7 +450,7 @@ protected CompilerConfiguration getCompilerConfiguration(List compileSou compilerConfiguration.setTargetVersion(target != null? target: DEFAULT_TARGET_VERSION); - compilerConfiguration.setSourceEncoding(encoding); + compilerConfiguration.setSourceEncoding(getEncoding()); if ((compilerArguments != null) || (compilerArgument != null)) { LinkedHashMap cplrArgsCopy = new LinkedHashMap(); @@ -503,7 +512,14 @@ protected CompilerConfiguration getCompilerConfiguration(List compileSou return compilerConfiguration; } - private String getMemoryValue(String setting) { + private String getEncoding() { + if (encoding != null) { + return encoding; + } + return mavenCompilerEncoding; + } + + private String getMemoryValue(String setting) { String value = null; // Allow '128' or '128m'