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

Add baseline-encoding plugin to force UTF-8 during compilation #1600

Merged
merged 3 commits into from
Jan 5, 2021

Conversation

pkoenig10
Copy link
Member

Before this PR

JavaCompile tasks use the platform charset by default. This is often UTF-8, but we have seen internal CI builds where the platform charset is US_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 to UTF-8 for all JavaCompile tasks.

@changelog-app
Copy link

changelog-app bot commented Jan 5, 2021

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Baseline now provides a com.palantir.baseline-encoding plugin to force UTF-8 in compilation tasks.

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from iamdanfox January 5, 2021 21:57
@pkoenig10 pkoenig10 requested review from carterkozak and removed request for iamdanfox January 5, 2021 21:57
@Override
public void apply(Project project) {
project.getTasks().withType(JavaCompile.class).configureEach(t -> {
t.getOptions().setEncoding("UTF-8");
Copy link
Contributor

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

Copy link
Contributor

@carterkozak carterkozak left a 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.

then:
BuildResult result = with('compileJava').build()
result.task(":compileJava").outcome == TaskOutcome.SUCCESS
result.output.contains("unmappable character")
Copy link
Member Author

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.

@bulldozer-bot bulldozer-bot bot merged commit a036972 into develop Jan 5, 2021
@bulldozer-bot bulldozer-bot bot deleted the pkoenig/utf8 branch January 5, 2021 22:25
@svc-autorelease
Copy link
Collaborator

Released 3.63.0

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

Successfully merging this pull request may close these issues.

3 participants