4848 */
4949@ SupportedOptions ({
5050 JoobyProcessor .OPT_DEBUG ,
51- JoobyProcessor .OPT_INCREMENTAL })
51+ JoobyProcessor .OPT_INCREMENTAL ,
52+ JoobyProcessor .OPT_SERVICES })
5253public class JoobyProcessor extends AbstractProcessor {
5354
5455 protected static final String OPT_DEBUG = "jooby.debug" ;
5556 protected static final String OPT_INCREMENTAL = "jooby.incremental" ;
57+ protected static final String OPT_SERVICES = "jooby.services" ;
5658
5759 private ProcessingEnvironment processingEnv ;
5860
@@ -66,15 +68,22 @@ public class JoobyProcessor extends AbstractProcessor {
6668
6769 private boolean debug ;
6870 private boolean incremental ;
71+ private boolean services ;
6972
7073 private int round ;
7174
7275 @ Override public Set <String > getSupportedOptions () {
7376 Set <String > options = new HashSet <>(super .getSupportedOptions ());
7477
7578 if (incremental ) {
76- // enables incremental annotation processing support in Gradle
77- options .add ("org.gradle.annotation.processing.aggregating" );
79+ // Enables incremental annotation processing support in Gradle.
80+ // If service provider configuration is being generated,
81+ // only 'aggregating' mode is supported since it's likely that
82+ // more then one originating element is passed to the Filer
83+ // API on writing the resource file - isolating mode does not
84+ // allow this.
85+ options .add (String .format ("org.gradle.annotation.processing.%s" ,
86+ services ? "aggregating" : "isolating" ));
7887 }
7988
8089 return options ;
@@ -94,8 +103,10 @@ public class JoobyProcessor extends AbstractProcessor {
94103
95104 debug = boolOpt (processingEnv , OPT_DEBUG , false );
96105 incremental = boolOpt (processingEnv , OPT_INCREMENTAL , true );
106+ services = boolOpt (processingEnv , OPT_SERVICES , true );
97107
98108 debug ("Incremental annotation processing is turned %s." , incremental ? "ON" : "OFF" );
109+ debug ("Generation of service provider configuration is turned %s." , services ? "ON" : "OFF" );
99110 }
100111
101112 @ Override
@@ -207,7 +218,9 @@ private void build(Filer filer) throws Exception {
207218 modules .put (type , moduleClass );
208219 }
209220
210- doServices (filer , modules );
221+ if (services ) {
222+ doServices (filer , modules );
223+ }
211224 }
212225
213226 private String signature (ExecutableElement method ) {
0 commit comments