Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding not applied when the compiler is forked #90

Closed
picpicpic opened this issue Dec 15, 2020 · 4 comments
Closed

Encoding not applied when the compiler is forked #90

picpicpic opened this issue Dec 15, 2020 · 4 comments
Assignees
Labels
Milestone

Comments

@picpicpic
Copy link

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

@bsorrentino
Copy link
Owner

Hi @picpicpic

Thanks for the detailed diagnosis, I got it. Essentially you need that encoding configuration should be set on javac cli when java compiler is forked

@bsorrentino
Copy link
Owner

bsorrentino commented Dec 20, 2020

Hi @picpicpic, I've fix issue and deployed 4.5-SNAPSHOT and 4.5-jdk8-SNAPSHOT.

Please take chance to test it and let me know

@picpicpic
Copy link
Author

Hi @bsorrentino,

I tested with the version 4.5-jdk8-SNAPSHOT and it's working 👍

Many thx!
Aldric

@bsorrentino
Copy link
Owner

I've released version 4.5-jdk8 with fix. I'm arranging also the official release 4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants