Skip to content

Encoding not applied when the compiler is forked #90

Closed
@picpicpic

Description

Hello,

It seems the encoding is not properly used when the compiler is forked.

In our case, we are using the maven-toolchains-plugin to choose the jdk which automatically set the fork property to true.

Context

  • maven-processor-plugin 4.4-jdk8
  • maven project is configured to use UTF-8 sources xml <project.build.sourceEncoding> tag.
  • the fork property is true or maven-toolchains-plugin is used to specify the jdk.
  • Some source files contains UTF-8 characters.

Currently
Our project fails due to unmappable character errors.

From the debug trace below, we see that :

  • the UTF-8 encoding is correctly configured by maven.
  • However, the encoding property is not passed to the javac process, hence the default encoding of the OS is used.

Expected
The encoding parameter should be passed to javac process.

Workaround
If we force the encoding arguments, the build is working

<compilerArguments>-encoding UTF-8</compilerArguments>

Debug trace

	[DEBUG]   (f) defaultOutputDirectory = XXX\target\generated-sources\apt
	[DEBUG]   (f) encoding = UTF-8
	[DEBUG]   (f) failOnError = true
	[DEBUG]   (f) fork = false
	[DEBUG]   (f) outputClassDirectory = XXX\target\classes
	[DEBUG]   (f) outputDiagnostics = true
	[DEBUG]   (f) pluginArtifacts = [org.bsc.maven:maven-processor-plugin:maven-plugin:4.4-jdk8:...
	[DEBUG]   (f) processors = [com.querydsl.apt.jpa.JPAAnnotationProcessor]
	[DEBUG]   (f) project = MavenProject: xxx:yyy:0.0.1-SNAPSHOT @ XXX\pom.xml
	[DEBUG]   (f) repoSession = org.eclipse.aether.DefaultRepositorySystemSession@6d14d6fe
	[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@6a0659ac
	[DEBUG]   (f) skip = false
	[DEBUG]   (f) skipSourcesUnchanged = false
	[DEBUG]   (f) sourceDirectory = XXX\src\main\java
	[DEBUG] -- end configuration --
	[DEBUG] Source directory: XXX\target\generated-sources\apt added
	[DEBUG] processing source directory [XXX\src\main\java]
	[DEBUG] PROCESSOR COMPILER FORKED!
	[DEBUG] javac option: -cp
	[DEBUG] javac option: XXX\src\main\resources;XXX\target\generated-resources;...
	[DEBUG] javac option: -sourcepath
	[DEBUG] javac option: XXX\src\main\java;...
	[DEBUG] javac option: -proc:only
	[DEBUG] javac option: -processor
	[DEBUG] javac option: com.querydsl.apt.jpa.JPAAnnotationProcessor
	[DEBUG] javac option: -d
	[DEBUG] javac option: XXX\target\classes
	[DEBUG] javac option: -s
	[DEBUG] javac option: XXX\target\generated-sources\apt
	[DEBUG] javac option: -source
	[DEBUG] javac option: 1.8
	[DEBUG] javac option: -target
	[DEBUG] javac option: 1.8
	XXX\src\main\MyClass.java:33: error: unmappable character for encoding ASCII
		 * La date de cr??ation ne doit pas etre null.

Regards
Aldric

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions