Skip to content

Commit 1addafc

Browse files
committed
Make it ready for merge
1 parent 2a7226a commit 1addafc

File tree

15 files changed

+278
-231
lines changed

15 files changed

+278
-231
lines changed

CHANGELOG.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
////
1717
18+
== Unreleased
19+
20+
* Added `log4j-changelog-maven-plugin` module and renamed `log4j.changelog.exporter.outputDirectory` property to `log4j.changelog.outputDirectory` (for https://github.com/apache/logging-log4j-tools/issues/20[#20] by Ralph Goers, Volkan Yazıcı)
21+
1822
== 0.1.0 (2023-01-10)
1923
20-
* Added `log4j-tools-bom` and `log4j-changelog` modules (for https://issues.apache.org/jira/browse/LOG4J2-3628[LOG4J2-3628] by `vy`)
24+
* Added `log4j-tools-bom` and `log4j-changelog` modules (for https://issues.apache.org/jira/browse/LOG4J2-3628[LOG4J2-3628] by Volkan Yazıcı)

README.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Tooling **internally** used by https://logging.apache.org/log4j/2.x/[the Apache
2424
xref:log4j-changelog/README.adoc[`log4j-changelog`]::
2525
Tooling to export AsciiDoc-formatted changelog files.
2626
27+
xref:log4j-changelog-maven-plugin/README.adoc[`log4j-changelog-maven-plugin`]::
28+
Maven plugin for xref:log4j-changelog/README.adoc[`log4j-changelog`].
29+
2730
== Distribution
2831
2932
In accordance with the Apache Software Foundation's release https://infra.apache.org/release-distribution.html[distribution policy] and https://infra.apache.org/release-publishing.html[creation process], project artifacts are _officially_ accessible from the following locations:
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
https://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+
18+
This project ships a Maven plugin providing convenient access to the `ChangelogExporter` and `ChangelogReleaser` of xref:../log4j-changelog/README.adoc[log4j-changelog].
19+
20+
== Exporting changelogs to AsciiDoc files
21+
22+
You can use the `export` goal wrapping xref:../log4j-changelog/README.adoc#qa-generate[`ChangelogExporter` to generate AsciiDoc files from a changelog directory].
23+
An example usage is shared below.
24+
25+
.`pom.xml` snippet that goes into the `project > build > plugins` block
26+
[source,xml]
27+
----
28+
<!-- export AsciiDoc-formatted sources to `target/generated-sources/site/asciidoc/changelog` -->
29+
<plugin>
30+
<groupId>org.apache.logging.log4j</groupId>
31+
<artifactId>log4j-changelog-maven-plugin</artifactId>
32+
<inherited>false</inherited>
33+
<executions>
34+
<execution>
35+
<id>generate-changelog</id>
36+
<goals>
37+
<goal>export</goal>
38+
</goals>
39+
</execution>
40+
</executions>
41+
</plugin>
42+
----
43+
44+
`export` goal by defaults runs during the `pre-site` phase and accepts the following configuration parameters:
45+
46+
`changelogDirectory`::
47+
Directory containing release folders composed of changelog entry XML files.
48+
It defaults to `${project.basedir}/src/changelog` and can be set using the `log4j.changelog.directory` property.
49+
50+
`outputDirectory`::
51+
Directory to write generated changelog files.
52+
It defaults to `${project.build.directory}/generated-sources/site/asciidoc/changelog` and can be set using the `log4j.changelog.exporter.outputDirectory` property.
53+
54+
== Populating a release changelog directory
55+
56+
You can use the `release` goal wrapping xref:../log4j-changelog/README.adoc#qa-deploy-release[`ChangelogReleaser` to populate a release changelog directory].
57+
An example usage is shared below.
58+
59+
[source,bash]
60+
----
61+
# Populate `src/changelog/<releaseVersion>` from `src/changelog/.<releaseVersionMajor>.x.x`
62+
./mvnw -N log4j-changelog:releaser -Dlog4j.changelog.releaseVersion=2.19.0
63+
----
64+
65+
`release` goal by defaults runs during the `validate` phase and accepts the following configuration parameters:
66+
67+
`changelogDirectory`::
68+
Directory containing release folders composed of changelog entry XML files.
69+
It defaults to `${project.basedir}/src/changelog` and can be set using the `log4j.changelog.directory` property.
70+
71+
`releaseVersion`::
72+
The version to be released.
73+
It can be set using the `log4j.changelog.releaseVersion` property.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
22+
<modelVersion>4.0.0</modelVersion>
23+
24+
<parent>
25+
<groupId>org.apache.logging.log4j</groupId>
26+
<artifactId>log4j-tools-parent</artifactId>
27+
<version>${revision}</version>
28+
<relativePath>../log4j-tools-parent/pom.xml</relativePath>
29+
</parent>
30+
31+
<artifactId>log4j-changelog-maven-plugin</artifactId>
32+
<packaging>maven-plugin</packaging>
33+
34+
<dependencies>
35+
36+
<dependency>
37+
<groupId>org.apache.logging.log4j</groupId>
38+
<artifactId>log4j-changelog</artifactId>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>org.apache.maven.plugin-tools</groupId>
43+
<artifactId>maven-plugin-annotations</artifactId>
44+
<scope>provided</scope>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>org.apache.maven</groupId>
49+
<artifactId>maven-plugin-api</artifactId>
50+
</dependency>
51+
52+
</dependencies>
53+
54+
<build>
55+
<plugins>
56+
<plugin>
57+
<groupId>org.apache.maven.plugins</groupId>
58+
<artifactId>maven-plugin-plugin</artifactId>
59+
<configuration>
60+
<goalPrefix>log4j-changelog</goalPrefix>
61+
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
62+
</configuration>
63+
<executions>
64+
<execution>
65+
<id>mojo-descriptor</id>
66+
<goals>
67+
<goal>descriptor</goal>
68+
</goals>
69+
</execution>
70+
</executions>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
75+
</project>

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

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,47 @@
1616
*/
1717
package org.apache.logging.log4j;
1818

19-
/*
20-
* Copyright 2001-2005 The Apache Software Foundation.
21-
*
22-
* Licensed under the Apache License, Version 2.0 (the "License");
23-
* you may not use this file except in compliance with the License.
24-
* You may obtain a copy of the License at
25-
*
26-
* http://www.apache.org/licenses/LICENSE-2.0
27-
*
28-
* Unless required by applicable law or agreed to in writing, software
29-
* distributed under the License is distributed on an "AS IS" BASIS,
30-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31-
* See the License for the specific language governing permissions and
32-
* limitations under the License.
33-
*/
34-
3519
import java.io.File;
3620

3721
import org.apache.logging.log4j.changelog.exporter.ChangelogExporter;
3822
import org.apache.logging.log4j.changelog.exporter.ChangelogExporterArgs;
3923

4024
import org.apache.maven.plugin.AbstractMojo;
41-
import org.apache.maven.plugin.MojoExecutionException;
4225
import org.apache.maven.plugins.annotations.LifecyclePhase;
4326
import org.apache.maven.plugins.annotations.Mojo;
4427
import org.apache.maven.plugins.annotations.Parameter;
4528

4629
/**
47-
* Goal which creates a changelog.
30+
* Goal exporting the changelog directory.
31+
*
32+
* @see ChangelogExporter
4833
*/
4934
@Mojo(name = "export", defaultPhase = LifecyclePhase.PRE_SITE)
5035
public class ExportMojo extends AbstractMojo {
36+
5137
/**
52-
* Location of the file.
38+
* Directory containing release folders composed of changelog entry XML files.
5339
*/
54-
@Parameter(defaultValue = "${project.build.directory}/generated-sources/site/asciidoc/changelog",
55-
property = "outputDir", required = true)
56-
private File outputDirectory;
40+
@Parameter(
41+
defaultValue = "${project.basedir}/src/changelog",
42+
property = ChangelogExporterArgs.CHANGELOG_DIRECTORY_PROPERTY_NAME,
43+
required = true)
44+
private File changelogDirectory;
5745

5846
/**
59-
* Location of the file.
47+
* Directory to write generated changelog files.
6048
*/
61-
@Parameter(defaultValue = "${project.basedir}/src/changelog", property = "changeLogDir", required = true)
62-
private File changeLogDirectory;
49+
@Parameter(
50+
defaultValue = "${project.build.directory}/generated-sources/site/asciidoc/changelog",
51+
property = ChangelogExporterArgs.OUTPUT_DIRECTORY_PROPERTY_NAME,
52+
required = true)
53+
private File outputDirectory;
6354

64-
public void execute() throws MojoExecutionException {
65-
ChangelogExporter.performExport(ChangelogExporterArgs.fromArgs(changeLogDirectory.toPath(),
66-
outputDirectory.toPath()));
55+
public void execute() {
56+
ChangelogExporterArgs args = ChangelogExporterArgs.fromArgs(
57+
changelogDirectory.toPath(),
58+
outputDirectory.toPath());
59+
ChangelogExporter.performExport(args);
6760
}
61+
6862
}

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

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,56 +16,44 @@
1616
*/
1717
package org.apache.logging.log4j;
1818

19-
/*
20-
* Copyright 2001-2005 The Apache Software Foundation.
21-
*
22-
* Licensed under the Apache License, Version 2.0 (the "License");
23-
* you may not use this file except in compliance with the License.
24-
* You may obtain a copy of the License at
25-
*
26-
* http://www.apache.org/licenses/LICENSE-2.0
27-
*
28-
* Unless required by applicable law or agreed to in writing, software
29-
* distributed under the License is distributed on an "AS IS" BASIS,
30-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31-
* See the License for the specific language governing permissions and
32-
* limitations under the License.
33-
*/
34-
3519
import java.io.File;
3620

3721
import org.apache.logging.log4j.changelog.releaser.ChangelogReleaser;
3822
import org.apache.logging.log4j.changelog.releaser.ChangelogReleaserArgs;
3923

4024
import org.apache.maven.plugin.AbstractMojo;
41-
import org.apache.maven.plugin.MojoExecutionException;
4225
import org.apache.maven.plugins.annotations.LifecyclePhase;
4326
import org.apache.maven.plugins.annotations.Mojo;
4427
import org.apache.maven.plugins.annotations.Parameter;
4528

4629
/**
47-
* Goal which creates changelog for a release.
30+
* Goal moving the contents of an unreleased changelog directory (e.g., {@code .2.x.x} to a released one (e.g., {@code 2.19.0}).
31+
*
32+
* @see ChangelogReleaser
4833
*/
4934
@Mojo(name = "release", defaultPhase = LifecyclePhase.VALIDATE)
5035
public class ReleaseMojo extends AbstractMojo {
36+
5137
/**
52-
* The release version.
38+
* Directory containing release folders composed of changelog entry XML files.
5339
*/
54-
@Parameter(property = "version", required = true)
55-
private String releaseVersion;
40+
@Parameter(
41+
defaultValue = "${project.basedir}/src/changelog",
42+
property = ChangelogReleaserArgs.CHANGELOG_DIRECTORY_PROPERTY_NAME,
43+
required = true)
44+
private File changelogDirectory;
5645

5746
/**
58-
* Location of the files.
47+
* The version to be released, e.g., {@code 2.19.0}.
5948
*/
60-
@Parameter(defaultValue = "${project.basedir}/src/changelog", property = "changeLogDir", required = true)
61-
private File changeLogDirectory;
49+
@Parameter(
50+
property = ChangelogReleaserArgs.RELEASE_VERSION_PROPERTY_NAME,
51+
required = true)
52+
private String releaseVersion;
6253

63-
public void execute() throws MojoExecutionException {
64-
try {
65-
ChangelogReleaser.performRelease(ChangelogReleaserArgs.fromArgs(changeLogDirectory.toPath(),
66-
releaseVersion));
67-
} catch (Exception ex) {
68-
throw new MojoExecutionException("Error performing release", ex);
69-
}
54+
public void execute() {
55+
ChangelogReleaserArgs args = ChangelogReleaserArgs.fromArgs(changelogDirectory.toPath(), releaseVersion);
56+
ChangelogReleaser.performRelease(args);
7057
}
58+
7159
}

log4j-changelog/README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ You need to use `ChangelogExporter` as follows:
260260
java \
261261
-cp /path/to/log4j-changelog.jar \
262262
-Dlog4j.changelog.directory=/path/to/changelog/directory \
263-
-Dlog4j.changelog.exporter.outputDirectory=/path/to/asciiDocOutputDirectory \
263+
-Dlog4j.changelog.outputDirectory=/path/to/asciiDocOutputDirectory \
264264
org.apache.logging.log4j.changelog.exporter.ChangelogExporter
265265
----
266266

log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/exporter/ChangelogExporter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static void main(final String[] mainArgs) {
3838
}
3939

4040
public static void performExport(final ChangelogExporterArgs args) {
41+
4142
// Find release directories
4243
final List<Path> releaseDirectories = findReleaseDirectories(args);
4344
final int releaseDirectoryCount = releaseDirectories.size();
@@ -107,6 +108,7 @@ public static void performExport(final ChangelogExporterArgs args) {
107108
// Export the release index
108109
final Path changelogIndexTemplateFile = ChangelogFiles.indexTemplateFile(args.changelogDirectory);
109110
exportIndex(args.outputDirectory, changelogReleases, changelogIndexTemplateFile);
111+
110112
}
111113

112114
private static List<Path> findReleaseDirectories(ChangelogExporterArgs args) {

log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/exporter/ChangelogExporterArgs.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222

2323
public final class ChangelogExporterArgs {
2424

25+
public static final String CHANGELOG_DIRECTORY_PROPERTY_NAME = "log4j.changelog.directory";
26+
27+
public static final String OUTPUT_DIRECTORY_PROPERTY_NAME = "log4j.changelog.outputDirectory";
28+
2529
final Path changelogDirectory;
2630

2731
final Path outputDirectory;
@@ -32,8 +36,8 @@ private ChangelogExporterArgs(final Path changelogDirectory, final Path outputDi
3236
}
3337

3438
static ChangelogExporterArgs fromSystemProperties() {
35-
final Path changelogDirectory = requireNonBlankPathProperty("log4j.changelog.directory");
36-
final Path outputDirectory = requireNonBlankPathProperty("log4j.changelog.exporter.outputDirectory");
39+
final Path changelogDirectory = requireNonBlankPathProperty(CHANGELOG_DIRECTORY_PROPERTY_NAME);
40+
final Path outputDirectory = requireNonBlankPathProperty(OUTPUT_DIRECTORY_PROPERTY_NAME);
3741
return new ChangelogExporterArgs(changelogDirectory, outputDirectory);
3842
}
3943

log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/importer/MavenChangesImporterArgs.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323

2424
final class MavenChangesImporterArgs {
2525

26+
public static final String CHANGELOG_DIRECTORY_PROPERTY_NAME = "log4j.changelog.directory";
27+
28+
public static final String CHANGES_XML_FILE_PROPERTY_NAME = "log4j.changelog.changesXmlFile";
29+
30+
public static final String RELEASE_VERSION_MAJOR_PROPERTY_NAME = "log4j.changelog.releaseVersionMajor";
31+
2632
final Path changelogDirectory;
2733

2834
final Path changesXmlFile;
@@ -36,10 +42,10 @@ private MavenChangesImporterArgs(final Path changelogDirectory, final Path chang
3642
}
3743

3844
static MavenChangesImporterArgs fromSystemProperties() {
39-
final Path changelogDirectory = requireNonBlankPathProperty("log4j.changelog.directory");
40-
final Path changesXmlFile = requireNonBlankPathProperty("log4j.changelog.changesXmlFile");
41-
final int releaseVersion = requireNonBlankIntProperty("log4j.changelog.releaseVersionMajor");
42-
return new MavenChangesImporterArgs(changelogDirectory, changesXmlFile, releaseVersion);
45+
final Path changelogDirectory = requireNonBlankPathProperty(CHANGELOG_DIRECTORY_PROPERTY_NAME);
46+
final Path changesXmlFile = requireNonBlankPathProperty(CHANGES_XML_FILE_PROPERTY_NAME);
47+
final int releaseVersionMajor = requireNonBlankIntProperty(RELEASE_VERSION_MAJOR_PROPERTY_NAME);
48+
return new MavenChangesImporterArgs(changelogDirectory, changesXmlFile, releaseVersionMajor);
4349
}
4450

4551
}

0 commit comments

Comments
 (0)