Skip to content

Commit 6914e16

Browse files
authored
Add skip parameter to all Maven goals (#121)
2 parents bb0347a + 842e23f commit 6914e16

File tree

10 files changed

+99
-37
lines changed

10 files changed

+99
-37
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.logging.log4j.changelog.maven;
18+
19+
import java.io.File;
20+
import org.apache.maven.plugin.AbstractMojo;
21+
import org.apache.maven.plugins.annotations.Parameter;
22+
23+
abstract class AbstractChangelogMojo extends AbstractMojo {
24+
25+
/**
26+
* Indicates if the execution should be skipped or not.
27+
*/
28+
@Parameter(property = "log4j.changelog.skip")
29+
boolean skip;
30+
31+
/**
32+
* Directory containing release folders composed of changelog entry XML files.
33+
*/
34+
@Parameter(
35+
defaultValue = "${project.basedir}/src/changelog",
36+
property = "log4j.changelog.directory",
37+
required = true)
38+
File changelogDirectory;
39+
}

log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ExportMojo.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.logging.log4j.changelog.exporter.ChangelogExporter;
2626
import org.apache.logging.log4j.changelog.exporter.ChangelogExporterArgs;
2727
import org.apache.logging.log4j.changelog.exporter.ChangelogExporterTemplate;
28-
import org.apache.maven.plugin.AbstractMojo;
2928
import org.apache.maven.plugins.annotations.LifecyclePhase;
3029
import org.apache.maven.plugins.annotations.Mojo;
3130
import org.apache.maven.plugins.annotations.Parameter;
@@ -36,20 +35,11 @@
3635
* @see ChangelogExporter
3736
*/
3837
@Mojo(name = "export", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true)
39-
public final class ExportMojo extends AbstractMojo {
38+
public final class ExportMojo extends AbstractChangelogMojo {
4039

4140
private static final String SOURCE_TARGET_TEMPLATE_PATTERN =
4241
"^\\.(.*)\\." + ChangelogFiles.templateFileNameExtension() + '$';
4342

44-
/**
45-
* Directory containing release folders composed of changelog entry XML files.
46-
*/
47-
@Parameter(
48-
defaultValue = "${project.basedir}/src/changelog",
49-
property = "log4j.changelog.directory",
50-
required = true)
51-
private File changelogDirectory;
52-
5343
/**
5444
* Templates that will be rendered with the release information of all releases, e.g., to generate an index page.
5545
*/
@@ -73,6 +63,10 @@ public final class ExportMojo extends AbstractMojo {
7363

7464
@Override
7565
public void execute() {
66+
if (skip) {
67+
getLog().info("Skipping changelog export");
68+
return;
69+
}
7670
final Set<ChangelogExporterTemplate> translatedIndexTemplates = toExporterTemplates(indexTemplates);
7771
final Set<ChangelogExporterTemplate> translatedReleaseChangelogTemplates =
7872
toExporterTemplates(changelogTemplates);

log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ImportMojo.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.apache.logging.log4j.changelog.importer.MavenChangesImporter;
2121
import org.apache.logging.log4j.changelog.importer.MavenChangesImporterArgs;
2222
import org.apache.logging.log4j.changelog.releaser.ChangelogReleaser;
23-
import org.apache.maven.plugin.AbstractMojo;
2423
import org.apache.maven.plugins.annotations.Mojo;
2524
import org.apache.maven.plugins.annotations.Parameter;
2625

@@ -30,16 +29,7 @@
3029
* @see ChangelogReleaser
3130
*/
3231
@Mojo(name = "import", threadSafe = true)
33-
public final class ImportMojo extends AbstractMojo {
34-
35-
/**
36-
* Directory containing release folders composed of changelog entry XML files.
37-
*/
38-
@Parameter(
39-
defaultValue = "${project.basedir}/src/changelog",
40-
property = "log4j.changelog.directory",
41-
required = true)
42-
private File changelogDirectory;
32+
public final class ImportMojo extends AbstractChangelogMojo {
4333

4434
/**
4535
* <a href="https://maven.apache.org/plugins/maven-changes-plugin/">maven-changes-plugin</a> source XML, {@code changes.xml}, location.
@@ -58,6 +48,10 @@ public final class ImportMojo extends AbstractMojo {
5848

5949
@Override
6050
public void execute() {
51+
if (skip) {
52+
getLog().info("Skipping changelog import");
53+
return;
54+
}
6155
final MavenChangesImporterArgs args =
6256
new MavenChangesImporterArgs(changelogDirectory.toPath(), changesXmlFile.toPath(), releaseVersionMajor);
6357
MavenChangesImporter.performImport(args);

log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/changelog/maven/ReleaseMojo.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616
*/
1717
package org.apache.logging.log4j.changelog.maven;
1818

19-
import java.io.File;
2019
import java.time.LocalDate;
2120
import java.time.ZoneId;
2221
import java.util.regex.Pattern;
2322
import org.apache.logging.log4j.changelog.releaser.ChangelogReleaser;
2423
import org.apache.logging.log4j.changelog.releaser.ChangelogReleaserArgs;
25-
import org.apache.maven.plugin.AbstractMojo;
2624
import org.apache.maven.plugins.annotations.LifecyclePhase;
2725
import org.apache.maven.plugins.annotations.Mojo;
2826
import org.apache.maven.plugins.annotations.Parameter;
@@ -33,16 +31,7 @@
3331
* @see ChangelogReleaser
3432
*/
3533
@Mojo(name = "release", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true)
36-
public final class ReleaseMojo extends AbstractMojo {
37-
38-
/**
39-
* Directory containing release folders composed of changelog entry XML files.
40-
*/
41-
@Parameter(
42-
defaultValue = "${project.basedir}/src/changelog",
43-
property = "log4j.changelog.directory",
44-
required = true)
45-
private File changelogDirectory;
34+
public final class ReleaseMojo extends AbstractChangelogMojo {
4635

4736
/**
4837
* The version to be released, e.g., {@code 2.19.0}.
@@ -66,6 +55,10 @@ public final class ReleaseMojo extends AbstractMojo {
6655

6756
@Override
6857
public void execute() {
58+
if (skip) {
59+
getLog().info("Skipping changelog release");
60+
return;
61+
}
6962
Pattern compiledVersionPattern = versionPattern != null ? Pattern.compile(versionPattern) : null;
7063
final ChangelogReleaserArgs args = new ChangelogReleaserArgs(
7164
changelogDirectory.toPath(),

log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractGeneratorMojo.java renamed to log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/AbstractDocgenMojo.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
import org.apache.maven.plugins.annotations.Parameter;
2222
import org.jspecify.annotations.Nullable;
2323

24-
abstract class AbstractGeneratorMojo extends AbstractMojo {
24+
abstract class AbstractDocgenMojo extends AbstractMojo {
25+
26+
/**
27+
* Indicates if the execution should be skipped or not.
28+
*/
29+
@Parameter(property = "log4j.docgen.skip")
30+
boolean skip;
2531

2632
/**
2733
* The paths of the plugin descriptor XML files.

log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/DocumentationGeneratorMojo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @see DocumentationGenerator
3434
*/
3535
@Mojo(name = "generate-documentation", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true)
36-
public class DocumentationGeneratorMojo extends AbstractGeneratorMojo {
36+
public class DocumentationGeneratorMojo extends AbstractDocgenMojo {
3737

3838
/**
3939
* The path to the FreeMarker template directory.
@@ -55,6 +55,10 @@ public class DocumentationGeneratorMojo extends AbstractGeneratorMojo {
5555

5656
@Override
5757
public void execute() {
58+
if (skip) {
59+
getLog().info("Skipping documentation generation");
60+
return;
61+
}
5862
final Set<PluginSet> pluginSets =
5963
PluginSets.ofDescriptorFilesAndFileMatchers(descriptorFiles, descriptorFileMatchers);
6064
final Predicate<String> classNameFilter = typeFilter != null ? typeFilter.createPredicate() : ignored -> true;

log4j-docgen-maven-plugin/src/main/java/org/apache/logging/log4j/docgen/maven/SchemaGeneratorMojo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @see SchemaGenerator
3535
*/
3636
@Mojo(name = "generate-schema", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true)
37-
public class SchemaGeneratorMojo extends AbstractGeneratorMojo {
37+
public class SchemaGeneratorMojo extends AbstractDocgenMojo {
3838

3939
/**
4040
* The version of the XSD
@@ -50,6 +50,10 @@ public class SchemaGeneratorMojo extends AbstractGeneratorMojo {
5050

5151
@Override
5252
public void execute() throws MojoExecutionException {
53+
if (skip) {
54+
getLog().info("Skipping schema generation");
55+
return;
56+
}
5357
final Set<PluginSet> pluginSets =
5458
PluginSets.ofDescriptorFilesAndFileMatchers(descriptorFiles, descriptorFileMatchers);
5559
final Predicate<String> classNameFilter = typeFilter != null ? typeFilter.createPredicate() : ignored -> true;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="https://logging.apache.org/xml/ns"
4+
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
5+
type="added">
6+
<issue id="121" link="https://github.com/apache/logging-log4j-tools/pull/121"/>
7+
<description format="asciidoc">Add `skip` parameter to all Maven goals</description>
8+
</entry>

src/site/antora/modules/ROOT/pages/log4j-changelog-maven-plugin.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ You can use the `export` goal as follows:
8686
8787
`export` goal by default runs during the `pre-site` phase and accepts the following configuration:
8888
89+
`skip` (parameter)::
90+
Indicates if the execution should be skipped or not.
91+
It defaults to `false` and can be set using the `log4j.changelog.skip` property.
92+
8993
`changelogDirectory` (parameter)::
9094
Directory containing release folders composed of changelog entry XML files.
9195
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
135139
136140
`release` goal does not have default phase and accepts the following configuration parameters:
137141
142+
`skip` (parameter)::
143+
Indicates if the execution should be skipped or not.
144+
It defaults to `false` and can be set using the `log4j.changelog.skip` property.
145+
138146
`changelogDirectory` (parameter)::
139147
Directory containing release folders composed of changelog entry XML files.
140148
It defaults to `${project.basedir}/src/changelog` and can be set using the `log4j.changelog.directory` property.

src/site/antora/modules/ROOT/pages/log4j-docgen-maven-plugin.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ The `generate-documentation` goal generates an AsciiDoc-formatted documentation
6969
</configuration>
7070
----
7171
72+
The `generate-documentation` goal configuration also accepts the following parameters:
73+
74+
`skip` (parameter)::
75+
Indicates if the execution should be skipped or not.
76+
It defaults to `false` and can be set using the `log4j.docgen.skip` property.
77+
7278
[#generate-schema]
7379
== Generate schema
7480
@@ -96,3 +102,9 @@ The `generate-schema` goal generates an XSD derived from the types loaded using
96102
97103
</configuration>
98104
----
105+
106+
The `generate-schema` goal configuration also accepts the following parameters:
107+
108+
`skip` (parameter)::
109+
Indicates if the execution should be skipped or not.
110+
It defaults to `false` and can be set using the `log4j.docgen.skip` property.

0 commit comments

Comments
 (0)