From c13513ed6109da2d4fb594a3bb4dd7933920e26a Mon Sep 17 00:00:00 2001 From: Daniel Mitterdorfer Date: Tue, 23 Aug 2016 15:15:22 +0200 Subject: [PATCH] Allow to enable annotation processing explicitly (#20117) In 1e91f3b we disabled annotation processors globally. However, some project like JMH need annotation processing, so we add an ability to selectively enabled annotation processing for certain projects by setting an external property in the corresponding Gradle build script. Note that `javac` would allow to set a specific annotation processor with the command line option `-processor`. However, due to a bug in Gradle we we cannot use this option and need to enable all annotation processors. --- benchmarks/build.gradle | 3 +++ .../groovy/org/elasticsearch/gradle/BuildPlugin.groovy | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index 186fdca44ea..3b8b92328e1 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -57,6 +57,9 @@ dependencies { } compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked" +// enable the JMH's BenchmarkProcessor to generate the final benchmark classes +// needs to be added separately otherwise Gradle will quote it and javac will fail +compileJava.options.compilerArgs.addAll(["-processor", "org.openjdk.jmh.generators.BenchmarkProcessor"]) compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked" forbiddenApis { diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index d996be40f87..4d7bee866b8 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -394,7 +394,13 @@ class BuildPlugin implements Plugin { * -serial because we don't use java serialization. */ // don't even think about passing args with -J-xxx, oracle will ask you to submit a bug report :) - options.compilerArgs << '-Werror' << '-proc:none' << '-Xlint:all,-path,-serial,-options,-deprecation' << '-Xdoclint:all' << '-Xdoclint:-missing' + options.compilerArgs << '-Werror' << '-Xlint:all,-path,-serial,-options,-deprecation' << '-Xdoclint:all' << '-Xdoclint:-missing' + + // either disable annotation processor completely (default) or allow to enable them if an annotation processor is explicitly defined + if (options.compilerArgs.contains("-processor") == false) { + options.compilerArgs << '-proc:none' + } + options.encoding = 'UTF-8' //options.incremental = true