Add `skip` parameter to all Maven goals (#121)
diff --git a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/AbstractChangelogMojo.java b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/AbstractChangelogMojo.java
new file mode 100644
index 0000000..223cf82
--- /dev/null
+++ b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/AbstractChangelogMojo.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.changelog.maven;
+
+import java.io.File;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+abstract class AbstractChangelogMojo extends AbstractMojo {
+
+ /**
+ * Indicates if the execution should be skipped or not.
+ */
+ @Parameter(property = "log4j.changelog.skip")
+ boolean skip;
+
+ /**
+ * Directory containing release folders composed of changelog entry XML files.
+ */
+ @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..37bf582 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.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,21 +35,12 @@
* @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.
*/
@Parameter(required = true)
@@ -73,6 +63,10 @@
@Override
public void execute() {
+ if (skip) {
+ getLog().info("Skipping changelog export");
+ 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..8fd7b89 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 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 @@
* @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,10 @@
@Override
public void execute() {
+ if (skip) {
+ getLog().info("Skipping changelog import");
+ 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..1ea8eaa 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 @@
* @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,10 @@
@Override
public void execute() {
+ if (skip) {
+ getLog().info("Skipping changelog release");
+ 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 89%
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.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..bbb5c66 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 @@
* @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,10 @@
@Override
public void execute() {
+ if (skip) {
+ getLog().info("Skipping documentation generation");
+ 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..5f4e884 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 @@
* @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,10 @@
@Override
public void execute() throws MojoExecutionException {
+ if (skip) {
+ getLog().info("Skipping schema generation");
+ 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 @@
`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 @@
`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 @@
</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 @@
</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.