-
Notifications
You must be signed in to change notification settings - Fork 134
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
Add baseline-encoding plugin to force UTF-8 during compilation #1600
Conversation
Generate changelog in
|
@Override | ||
public void apply(Project project) { | ||
project.getTasks().withType(JavaCompile.class).configureEach(t -> { | ||
t.getOptions().setEncoding("UTF-8"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would prefer to rename t -> compileJavaTask
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, one minor naming nit. Merge when you're ready.
850d003
to
ccb6d69
Compare
27046b1
to
aa6baf4
Compare
then: | ||
BuildResult result = with('compileJava').build() | ||
result.task(":compileJava").outcome == TaskOutcome.SUCCESS | ||
result.output.contains("unmappable character") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compilation doesn't actually fail when encountering unmappable characters - those characters are just replaced with the unicode replacement character.
Released 3.63.0 |
Before this PR
JavaCompile
tasks use the platform charset by default. This is oftenUTF-8
, but we have seen internal CI builds where the platform charset isUS_ASCII
. This can lead to compilation failures if source files contains non-ASCII characters.After this PR
Baseline now provides a
baseline-encoding
plugin that set the encoding toUTF-8
for allJavaCompile
tasks.