Force javac to use -encoding UTF-8
Since I3778f9c8 we have had non-ASCII characters in our source files. javac may decide to read the locale from its environment, which fails on such source files, causing warnings at best and test failures at worst. Hack our default java rule defs to pass -encoding. Change-Id: I53dfd2d551eed7c1c1fa8ef5cfcfb726d67e3a62
This commit is contained in:

committed by
David Pursehouse

parent
837a675e5e
commit
2a25188ebc
@@ -20,18 +20,38 @@ include_defs('//tools/java_doc.defs')
|
||||
include_defs('//tools/java_sources.defs')
|
||||
import copy
|
||||
|
||||
# Add AutoValue support to java_library.
|
||||
# Set defaults on java rules:
|
||||
# - Add AutoValue annotation processing support.
|
||||
# - Treat source files as UTF-8.
|
||||
|
||||
_buck_java_library = java_library
|
||||
def java_library(*args, **kwargs):
|
||||
_set_auto_value(kwargs)
|
||||
_munge_args(kwargs)
|
||||
_buck_java_library(*args, **kwargs)
|
||||
|
||||
# Add AutoValue support to java_test.
|
||||
_buck_java_test = java_test
|
||||
def java_test(*args, **kwargs):
|
||||
_set_auto_value(kwargs)
|
||||
_munge_args(kwargs)
|
||||
_buck_java_test(*args, **kwargs)
|
||||
|
||||
|
||||
# Munge kwargs to set Gerrit-specific defaults.
|
||||
def _munge_args(kwargs):
|
||||
_set_auto_value(kwargs)
|
||||
_set_extra_arguments(kwargs)
|
||||
|
||||
def _set_extra_arguments(kwargs):
|
||||
ext = 'extra_arguments'
|
||||
if ext not in kwargs:
|
||||
kwargs[ext] = []
|
||||
extra_args = kwargs[ext]
|
||||
|
||||
for arg in extra_args:
|
||||
if arg.startswith('-encoding'):
|
||||
return
|
||||
|
||||
extra_args.extend(['-encoding', 'UTF-8'])
|
||||
|
||||
def _set_auto_value(kwargs):
|
||||
apk = 'annotation_processors'
|
||||
if apk not in kwargs:
|
||||
@@ -47,6 +67,7 @@ def _set_auto_value(kwargs):
|
||||
aps.extend(AUTO_VALUE_PROCESSORS)
|
||||
apds.extend(AUTO_VALUE_PROCESSOR_DEPS)
|
||||
|
||||
|
||||
def genantlr(
|
||||
name,
|
||||
srcs,
|
||||
|
Reference in New Issue
Block a user