I can't tell about gradle, but in maven you can pass compile time arguments in the following way
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<generatedSourcesDirectory>${project.build.directory}/generated-sources/</generatedSourcesDirectory>
<annotationProcessors>
<annotationProcessor>org.rapster.xxx.xxx.xxComponentProcessor</annotationProcessor>
</annotationProcessors>
<compilerArgs>
<arg>-Awidget=something</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
This compile time argument can be read in your annotation processor by the following snippet in init function of processor
this.widget = processingEnv.getOptions().get("widget");
You can use this property to do certain conditional action.
Same can be done via gradle, I believe