Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,20 +35,11 @@
* @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.
*/
Expand All @@ -73,6 +63,10 @@ public final class ExportMojo extends AbstractMojo {

@Override
public void execute() {
if (skip) {
getLog().info("Skipping changelog export");
return;
}
final Set<ChangelogExporterTemplate> translatedIndexTemplates = toExporterTemplates(indexTemplates);
final Set<ChangelogExporterTemplate> translatedReleaseChangelogTemplates =
toExporterTemplates(changelogTemplates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.
Expand All @@ -58,6 +48,10 @@ public final class ImportMojo extends AbstractMojo {

@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
Expand All @@ -66,6 +55,10 @@ public final class ReleaseMojo extends AbstractMojo {

@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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -55,6 +55,10 @@ public class DocumentationGeneratorMojo extends AbstractGeneratorMojo {

@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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,6 +50,10 @@ public class SchemaGeneratorMojo extends AbstractGeneratorMojo {

@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;
Expand Down
8 changes: 8 additions & 0 deletions src/changelog/.0.x.x/add-maven-skip.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions src/site/antora/modules/ROOT/pages/log4j-docgen-maven-plugin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.