Skip to content

Commit

Permalink
Add log4j.docgen.skip argument to the DescriptorGenerator plugin …
Browse files Browse the repository at this point in the history
…processor
  • Loading branch information
vy committed May 22, 2024
1 parent 93612c7 commit f400131
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
@ServiceProvider(value = Processor.class, resolution = Resolution.OPTIONAL)
@SupportedAnnotationTypes({"org.apache.logging.log4j.core.config.plugins.*", "org.apache.logging.log4j.plugins.*"})
@SupportedOptions({
DescriptorGenerator.SKIP_KEY,
DescriptorGenerator.DESCRIPTOR_FILE_PATH_OPTION_KEY,
DescriptorGenerator.GROUP_ID_OPTION_KEY,
DescriptorGenerator.ARTIFACT_ID_OPTION_KEY,
Expand All @@ -98,6 +99,8 @@
@NullMarked
public class DescriptorGenerator extends AbstractProcessor {

static final String SKIP_KEY = "log4j.docgen.skip";

static final String DESCRIPTOR_FILE_PATH_OPTION_KEY = "log4j.docgen.descriptorFilePath";

static final String GROUP_ID_OPTION_KEY = "log4j.docgen.groupId";
Expand Down Expand Up @@ -141,6 +144,8 @@ public class DescriptorGenerator extends AbstractProcessor {

private final Set<TypeElement> scalarTypesToDocument = new HashSet<>();

private boolean skipped;

private Predicate<String> classNameFilter;

private PluginSet pluginSet;
Expand Down Expand Up @@ -170,6 +175,7 @@ public class DescriptorGenerator extends AbstractProcessor {
@Override
public synchronized void init(final ProcessingEnvironment processingEnv) {
super.init(processingEnv);
skipped = Boolean.parseBoolean(getOption(processingEnv, SKIP_KEY));
classNameFilter = createClassNameFilter(processingEnv);
pluginSet = createPluginSet(processingEnv);
descriptorFilePath = Path.of(requireOption(processingEnv, DESCRIPTOR_FILE_PATH_OPTION_KEY));
Expand Down Expand Up @@ -252,6 +258,9 @@ public SourceVersion getSupportedSourceVersion() {

@Override
public boolean process(final Set<? extends TypeElement> unused, final RoundEnvironment roundEnv) {
if (skipped) {
return false;
}
// First step: document plugins
populatePluginTypesToDocument(roundEnv);
pluginTypesToDocument.forEach(this::addPluginDocumentation);
Expand Down
7 changes: 7 additions & 0 deletions src/changelog/.0.x.x/add-processor-skip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="added">
<description format="asciidoc">Add `log4j.docgen.skip` argument to the `DescriptorGenerator` plugin processor</description>
</entry>
1 change: 1 addition & 0 deletions src/site/antora/modules/ROOT/pages/log4j-docgen.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Users are recommended to integrate this annotation processor into their build:
</annotationProcessorPaths>
<compilerArgs combine.children="append">
<!-- Provide `org.apache.logging.log4j.docgen.processor.DescriptorGenerator` arguments: -->
<arg>-Alog4j.docgen.skip=false</arg><!-- optional (defaults to `false`) -->
<arg>-Alog4j.docgen.descriptorFilePath=${project.build.directory}/${project.artifactId}-plugins.xml</arg>
<arg>-Alog4j.docgen.groupId=${project.groupId}</arg>
<arg>-Alog4j.docgen.artifactId=${project.artifactId}</arg>
Expand Down

0 comments on commit f400131

Please sign in to comment.