diff --git a/Documentation/dev-buck.txt b/Documentation/dev-buck.txt index e677ce5e1d..5dfb3677be 100644 --- a/Documentation/dev-buck.txt +++ b/Documentation/dev-buck.txt @@ -685,6 +685,25 @@ Watchman can either be de-installed or disabled. See link:#buck-daemon[Using Buck daemon] section above how to temporarily disable `buckd`. +== Error Prone integration + +link:http://errorprone.info[Error Prone] is a static analysis tool for +Java that catches common programming mistakes at compile-time. It can +be permanenty or instantly activated. For permanent activation, add these +lines to your `.buckconfig.local` file in gerrit tree: + +``` + [sanitizers] + error_prone = 1 +``` + +For instant activation, pass this config option to the `build` or `test` +commands: + +``` + buck build --config sanitizers.error_prone=1 gerrit +``` + == Troubleshooting Buck In some cases problems with Buck itself need to be investigated. See for example diff --git a/lib/BUCK b/lib/BUCK index ad860ff12d..96365eb5d3 100644 --- a/lib/BUCK +++ b/lib/BUCK @@ -310,3 +310,10 @@ maven_jar( sha1 = '198ea005f41219f038f4291f0b0e9f3259730e92', license = 'icu4j', ) + +maven_jar( + name = 'errorprone', + id = 'com.google.errorprone:error_prone_ant:2.0.15', + sha1 = '607e3866e2ee25b74708c2898f84eac2f5452d2f', + license = 'Apache2.0', +) diff --git a/tools/default.defs b/tools/default.defs index fb4c6de556..fa1800b50a 100644 --- a/tools/default.defs +++ b/tools/default.defs @@ -41,9 +41,15 @@ def java_test(*args, **kwargs): # Munge kwargs to set Gerrit-specific defaults. def _munge_args(kwargs): + if read_config('sanitizers', 'error_prone'): + _set_error_prone(kwargs) _set_auto_value(kwargs) _set_extra_arguments(kwargs) +def _set_error_prone(kwargs): + kwargs['javac_jar'] = '//lib:errorprone' + kwargs['compiler_class_name'] = 'com.google.errorprone.ErrorProneJavaCompiler' + def _set_extra_arguments(kwargs): ext = 'extra_arguments' if ext not in kwargs: