diff options
author | zaaarf <zaaarf@proton.me> | 2023-05-26 17:56:33 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-05-26 17:56:33 +0200 |
commit | a90af3bb4b156ea937a2e3507e9f0e15f70c882b (patch) | |
tree | 59bab511ba10c0618aa5d54ae3e3ff3f42924bd1 /src/main/java/ftbsc | |
parent | d3ebad7260bb273ddbba3286f91510c01d835268 (diff) |
feat: option to skip service provider generation
Diffstat (limited to 'src/main/java/ftbsc')
-rw-r--r-- | src/main/java/ftbsc/lll/processor/LilleroProcessor.java | 14 | ||||
-rw-r--r-- | src/main/java/ftbsc/lll/processor/tools/ProcessorOptions.java | 17 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/main/java/ftbsc/lll/processor/LilleroProcessor.java b/src/main/java/ftbsc/lll/processor/LilleroProcessor.java index 1b710b0..0f6935a 100644 --- a/src/main/java/ftbsc/lll/processor/LilleroProcessor.java +++ b/src/main/java/ftbsc/lll/processor/LilleroProcessor.java @@ -36,9 +36,8 @@ import static ftbsc.lll.processor.tools.JavaPoetUtils.*; * The actual annotation processor behind the magic. * It (implicitly) implements the {@link Processor} interface by extending {@link AbstractProcessor}. */ -@SupportedAnnotationTypes({"ftbsc.lll.processor.annotations.Patch", "ftbsc.lll.processor.annotations.RegisterBareInjector"}) +@SupportedAnnotationTypes({"ftbsc.lll.processor.annotations.Patch", "ftbsc.lll.processor.annotations.BareInjector"}) @SupportedSourceVersion(SourceVersion.RELEASE_8) -@SupportedOptions({"mappingsFile", "anonymousClassWarning", "obfuscateInjectorMetadata"}) public class LilleroProcessor extends AbstractProcessor { /** * A {@link Set} of {@link String}s that will contain the fully qualified names @@ -52,6 +51,15 @@ public class LilleroProcessor extends AbstractProcessor { public final ProcessorOptions options = new ProcessorOptions(processingEnv); /** + * Method overriding default implementation to manually pass supported options. + * @return a {@link Set} of options supported by this processor. + */ + @Override + public Set<String> getSupportedOptions() { + return ProcessorOptions.SUPPORTED; + } + + /** * Where the actual processing happens. * It filters through whatever annotated class it's fed, and checks whether it contains * the required information. It then generates injectors and a service provider for every @@ -82,7 +90,7 @@ public class LilleroProcessor extends AbstractProcessor { } } } - if (!this.injectors.isEmpty()) { + if (!this.options.noServiceProvider && !this.injectors.isEmpty()) { generateServiceProvider(); return true; } else return false; diff --git a/src/main/java/ftbsc/lll/processor/tools/ProcessorOptions.java b/src/main/java/ftbsc/lll/processor/tools/ProcessorOptions.java index 9bbdd10..0ef8a18 100644 --- a/src/main/java/ftbsc/lll/processor/tools/ProcessorOptions.java +++ b/src/main/java/ftbsc/lll/processor/tools/ProcessorOptions.java @@ -9,12 +9,24 @@ import java.io.*; import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; /** * Class in charge of containing, parsing and processing all processor options, * from the simpler booleans to the more complicated mapper. */ public class ProcessorOptions { + + /** + * A {@link Set} of options currently supported by the processor. + */ + public static final Set<String> SUPPORTED = new HashSet<>(Arrays.asList( + "mappingsFile", "anonymousClassWarning", "obfuscateInjectorMetadata", + "noServiceProvider" + )); + /** * The environment the processor is acting in. */ @@ -38,6 +50,10 @@ public class ProcessorOptions { */ public final boolean obfuscateInjectorMetadata; + /** + * Whether the processor should skip the generation of the service provider. + */ + public final boolean noServiceProvider; /** * The public constructor, parses and stores all given arguments. @@ -71,6 +87,7 @@ public class ProcessorOptions { } this.anonymousClassWarning = parseBooleanArg(env.getOptions().get("anonymousClassWarning"), true); this.obfuscateInjectorMetadata = parseBooleanArg(env.getOptions().get("obfuscateInjectorMetadata"), true); + this.noServiceProvider = parseBooleanArg(env.getOptions().get("noServiceProvider"), false); } /** |