Skip to content

Commit

Permalink
373759 compiler should honor project.build.sourceEncoding
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jsievers committed Apr 23, 2012
1 parent 2c97b2f commit d30f56b
Showing 1 changed file with 20 additions and 4 deletions.
Expand Up @@ -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
Expand Down Expand Up @@ -441,7 +450,7 @@ protected CompilerConfiguration getCompilerConfiguration(List<String> compileSou

compilerConfiguration.setTargetVersion(target != null? target: DEFAULT_TARGET_VERSION);

compilerConfiguration.setSourceEncoding(encoding);
compilerConfiguration.setSourceEncoding(getEncoding());

if ((compilerArguments != null) || (compilerArgument != null)) {
LinkedHashMap cplrArgsCopy = new LinkedHashMap();
Expand Down Expand Up @@ -503,7 +512,14 @@ protected CompilerConfiguration getCompilerConfiguration(List<String> 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'
Expand Down

0 comments on commit d30f56b

Please sign in to comment.