This is an automated email from the ASF dual-hosted git repository. vy pushed a commit to branch feature/maven-skip in repository https://gitbox.apache.org/repos/asf/logging-log4j-tools.git
commit de4e0fee897c1b83bf68700bea8e9f6300f35d06 Author: Volkan Yazıcı <vol...@yazi.ci> AuthorDate: Wed May 8 10:02:41 2024 +0200 Add `skip` parameter to all Maven goals --- .../changelog/maven/AbstractChangelogMojo.java | 35 +++++++--------------- .../logging/log4j/changelog/maven/ExportMojo.java | 15 +++------- .../logging/log4j/changelog/maven/ImportMojo.java | 15 +++------- .../logging/log4j/changelog/maven/ReleaseMojo.java | 16 +++------- ...tGeneratorMojo.java => AbstractDocgenMojo.java} | 8 ++++- .../docgen/maven/DocumentationGeneratorMojo.java | 5 +++- .../log4j/docgen/maven/SchemaGeneratorMojo.java | 5 +++- src/changelog/.0.x.x/add-maven-skip.xml | 8 +++++ .../ROOT/pages/log4j-changelog-maven-plugin.adoc | 8 +++++ .../ROOT/pages/log4j-docgen-maven-plugin.adoc | 12 ++++++++ 10 files changed, 66 insertions(+), 61 deletions(-) diff --git a/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractGeneratorMojo.java b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/AbstractChangelogMojo.java similarity index 50% copy from log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractGeneratorMojo.java copy to log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/AbstractChangelogMojo.java index 36603ba..223cf82 100644 --- a/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractGeneratorMojo.java +++ b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/AbstractChangelogMojo.java @@ -14,39 +14,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.logging.log4j.docgen.maven; +package org.apache.logging.log4j.changelog.maven; import java.io.File; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugins.annotations.Parameter; -import org.jspecify.annotations.Nullable; -abstract class AbstractGeneratorMojo extends AbstractMojo { +abstract class AbstractChangelogMojo extends AbstractMojo { /** - * The paths of the plugin descriptor XML files. - * <p> - * If you want to provide to a multitude of files, you might want to use {@link #descriptorFileMatchers} instead. - * </p> + * Indicates if the execution should be skipped or not. */ - @Nullable - @Parameter(property = "log4j.docgen.descriptorFiles") - File[] descriptorFiles; + @Parameter(property = "log4j.changelog.skip") + boolean skip; /** - * The {@link java.nio.file.FileSystem#getPathMatcher(String) PathMatcher}s to populate the paths of the plugin descriptor XML files. - * <p> - * If you want to refer to a particular file, you might want to use {@link #descriptorFiles} instead. - * </p> + * Directory containing release folders composed of changelog entry XML files. */ - @Nullable - @Parameter - PathMatcherMojo[] descriptorFileMatchers; - - /** - * Predicate for filtering types that the generator will operate on. - */ - @Nullable - @Parameter - TypeFilterMojo typeFilter; + @Parameter( + defaultValue = "${project.basedir}/src/changelog", + property = "log4j.changelog.directory", + required = true) + File changelogDirectory; } diff --git a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ExportMojo.java b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ExportMojo.java index d051f37..4c5877d 100644 --- a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ExportMojo.java +++ b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ExportMojo.java @@ -25,7 +25,6 @@ import org.apache.logging.log4j.changelog.ChangelogFiles; import org.apache.logging.log4j.changelog.exporter.ChangelogExporter; import org.apache.logging.log4j.changelog.exporter.ChangelogExporterArgs; import org.apache.logging.log4j.changelog.exporter.ChangelogExporterTemplate; -import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -36,20 +35,11 @@ import org.apache.maven.plugins.annotations.Parameter; * @see ChangelogExporter */ @Mojo(name = "export", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true) -public final class ExportMojo extends AbstractMojo { +public final class ExportMojo extends AbstractChangelogMojo { private static final String SOURCE_TARGET_TEMPLATE_PATTERN = "^\\.(.*)\\." + ChangelogFiles.templateFileNameExtension() + '$'; - /** - * Directory containing release folders composed of changelog entry XML files. - */ - @Parameter( - defaultValue = "${project.basedir}/src/changelog", - property = "log4j.changelog.directory", - required = true) - private File changelogDirectory; - /** * Templates that will be rendered with the release information of all releases, e.g., to generate an index page. */ @@ -73,6 +63,9 @@ public final class ExportMojo extends AbstractMojo { @Override public void execute() { + if (skip) { + return; + } final Set<ChangelogExporterTemplate> translatedIndexTemplates = toExporterTemplates(indexTemplates); final Set<ChangelogExporterTemplate> translatedReleaseChangelogTemplates = toExporterTemplates(changelogTemplates); diff --git a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ImportMojo.java b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ImportMojo.java index 05249bf..64a5a83 100644 --- a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ImportMojo.java +++ b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ImportMojo.java @@ -20,7 +20,6 @@ import java.io.File; import org.apache.logging.log4j.changelog.importer.MavenChangesImporter; import org.apache.logging.log4j.changelog.importer.MavenChangesImporterArgs; import org.apache.logging.log4j.changelog.releaser.ChangelogReleaser; -import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -30,16 +29,7 @@ import org.apache.maven.plugins.annotations.Parameter; * @see ChangelogReleaser */ @Mojo(name = "import", threadSafe = true) -public final class ImportMojo extends AbstractMojo { - - /** - * Directory containing release folders composed of changelog entry XML files. - */ - @Parameter( - defaultValue = "${project.basedir}/src/changelog", - property = "log4j.changelog.directory", - required = true) - private File changelogDirectory; +public final class ImportMojo extends AbstractChangelogMojo { /** * <a href="https://maven.apache.org/plugins/maven-changes-plugin/">maven-changes-plugin</a> source XML, {@code changes.xml}, location. @@ -58,6 +48,9 @@ public final class ImportMojo extends AbstractMojo { @Override public void execute() { + if (skip) { + return; + } final MavenChangesImporterArgs args = new MavenChangesImporterArgs(changelogDirectory.toPath(), changesXmlFile.toPath(), releaseVersionMajor); MavenChangesImporter.performImport(args); diff --git a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ReleaseMojo.java b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ReleaseMojo.java index 01204b6..aa4c8e5 100644 --- a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ReleaseMojo.java +++ b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ReleaseMojo.java @@ -16,13 +16,11 @@ */ package org.apache.logging.log4j.changelog.maven; -import java.io.File; import java.time.LocalDate; import java.time.ZoneId; import java.util.regex.Pattern; import org.apache.logging.log4j.changelog.releaser.ChangelogReleaser; import org.apache.logging.log4j.changelog.releaser.ChangelogReleaserArgs; -import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -33,16 +31,7 @@ import org.apache.maven.plugins.annotations.Parameter; * @see ChangelogReleaser */ @Mojo(name = "release", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true) -public final class ReleaseMojo extends AbstractMojo { - - /** - * Directory containing release folders composed of changelog entry XML files. - */ - @Parameter( - defaultValue = "${project.basedir}/src/changelog", - property = "log4j.changelog.directory", - required = true) - private File changelogDirectory; +public final class ReleaseMojo extends AbstractChangelogMojo { /** * The version to be released, e.g., {@code 2.19.0}. @@ -66,6 +55,9 @@ public final class ReleaseMojo extends AbstractMojo { @Override public void execute() { + if (skip) { + return; + } Pattern compiledVersionPattern = versionPattern != null ? Pattern.compile(versionPattern) : null; final ChangelogReleaserArgs args = new ChangelogReleaserArgs( changelogDirectory.toPath(), diff --git a/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractGeneratorMojo.java b/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractDocgenMojo.java similarity index 90% rename from log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractGeneratorMojo.java rename to log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractDocgenMojo.java index 36603ba..4831e76 100644 --- a/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractGeneratorMojo.java +++ b/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractDocgenMojo.java @@ -21,7 +21,13 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugins.annotations.Parameter; import org.jspecify.annotations.Nullable; -abstract class AbstractGeneratorMojo extends AbstractMojo { +abstract class AbstractDocgenMojo extends AbstractMojo { + + /** + * Indicates if the execution should be skipped or not. + */ + @Parameter(property = "log4j.docgen.skip") + boolean skip; /** * The paths of the plugin descriptor XML files. diff --git a/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/DocumentationGeneratorMojo.java b/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/DocumentationGeneratorMojo.java index 86c5574..aa230d6 100644 --- a/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/DocumentationGeneratorMojo.java +++ b/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/DocumentationGeneratorMojo.java @@ -33,7 +33,7 @@ import org.apache.maven.plugins.annotations.Parameter; * @see DocumentationGenerator */ @Mojo(name = "generate-documentation", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true) -public class DocumentationGeneratorMojo extends AbstractGeneratorMojo { +public class DocumentationGeneratorMojo extends AbstractDocgenMojo { /** * The path to the FreeMarker template directory. @@ -55,6 +55,9 @@ public class DocumentationGeneratorMojo extends AbstractGeneratorMojo { @Override public void execute() { + if (skip) { + return; + } final Set<PluginSet> pluginSets = PluginSets.ofDescriptorFilesAndFileMatchers(descriptorFiles, descriptorFileMatchers); final Predicate<String> classNameFilter = typeFilter != null ? typeFilter.createPredicate() : ignored -> true; diff --git a/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/SchemaGeneratorMojo.java b/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/SchemaGeneratorMojo.java index 7f16de8..5fe8edb 100644 --- a/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/SchemaGeneratorMojo.java +++ b/log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/SchemaGeneratorMojo.java @@ -34,7 +34,7 @@ import org.apache.maven.plugins.annotations.Parameter; * @see SchemaGenerator */ @Mojo(name = "generate-schema", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true) -public class SchemaGeneratorMojo extends AbstractGeneratorMojo { +public class SchemaGeneratorMojo extends AbstractDocgenMojo { /** * The version of the XSD @@ -50,6 +50,9 @@ public class SchemaGeneratorMojo extends AbstractGeneratorMojo { @Override public void execute() throws MojoExecutionException { + if (skip) { + return; + } final Set<PluginSet> pluginSets = PluginSets.ofDescriptorFilesAndFileMatchers(descriptorFiles, descriptorFileMatchers); final Predicate<String> classNameFilter = typeFilter != null ? typeFilter.createPredicate() : ignored -> true; diff --git a/src/changelog/.0.x.x/add-maven-skip.xml b/src/changelog/.0.x.x/add-maven-skip.xml new file mode 100644 index 0000000..0c23cad --- /dev/null +++ b/src/changelog/.0.x.x/add-maven-skip.xml @@ -0,0 +1,8 @@ +<?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"> + <issue id="121" link="https://github.com/apache/logging-log4j-tools/pull/121"/> + <description format="asciidoc">Add `skip` parameter to all Maven goals</description> +</entry> diff --git a/src/site/antora/modules/ROOT/pages/log4j-changelog-maven-plugin.adoc b/src/site/antora/modules/ROOT/pages/log4j-changelog-maven-plugin.adoc index b93b248..c4d9a47 100644 --- a/src/site/antora/modules/ROOT/pages/log4j-changelog-maven-plugin.adoc +++ b/src/site/antora/modules/ROOT/pages/log4j-changelog-maven-plugin.adoc @@ -86,6 +86,10 @@ You can use the `export` goal as follows: `export` goal by default runs during the `pre-site` phase and accepts the following configuration: +`skip` (parameter):: +Indicates if the execution should be skipped or not. +It defaults to `false` and can be set using the `log4j.changelog.skip` property. + `changelogDirectory` (parameter):: Directory containing release folders composed of changelog entry XML files. It defaults to `${project.basedir}/src/changelog` and can be set using the `log4j.changelog.directory` property. @@ -135,6 +139,10 @@ Note that above we are using `-N` (`--non-recursive`) to avoid visiting submodul `release` goal does not have default phase and accepts the following configuration parameters: +`skip` (parameter):: +Indicates if the execution should be skipped or not. +It defaults to `false` and can be set using the `log4j.changelog.skip` property. + `changelogDirectory` (parameter):: Directory containing release folders composed of changelog entry XML files. It defaults to `${project.basedir}/src/changelog` and can be set using the `log4j.changelog.directory` property. diff --git a/src/site/antora/modules/ROOT/pages/log4j-docgen-maven-plugin.adoc b/src/site/antora/modules/ROOT/pages/log4j-docgen-maven-plugin.adoc index 7b824b4..7b7f623 100644 --- a/src/site/antora/modules/ROOT/pages/log4j-docgen-maven-plugin.adoc +++ b/src/site/antora/modules/ROOT/pages/log4j-docgen-maven-plugin.adoc @@ -69,6 +69,12 @@ The `generate-documentation` goal generates an AsciiDoc-formatted documentation </configuration> ---- +The `generate-documentation` goal configuration also accepts the following parameters: + +`skip` (parameter):: +Indicates if the execution should be skipped or not. +It defaults to `false` and can be set using the `log4j.docgen.skip` property. + [#generate-schema] == Generate schema @@ -96,3 +102,9 @@ The `generate-schema` goal generates an XSD derived from the types loaded using </configuration> ---- + +The `generate-schema` goal configuration also accepts the following parameters: + +`skip` (parameter):: +Indicates if the execution should be skipped or not. +It defaults to `false` and can be set using the `log4j.docgen.skip` property.