mirror of
https://github.com/zaaarf/lillero-processor.git
synced 2024-11-25 02:14:50 +01:00
feat: option to skip service provider generation
This commit is contained in:
parent
d3ebad7260
commit
a90af3bb4b
2 changed files with 28 additions and 3 deletions
|
@ -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
|
||||
|
@ -51,6 +50,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
|
||||
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue