You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2024/04/01 11:38:21 UTC

(logging-log4j-transform) 01/02: Move code generation to `log4j-codegen` artifact

This is an automated email from the ASF dual-hosted git repository.

pkarwasz pushed a commit to branch feature/log4j-codegen
in repository https://gitbox.apache.org/repos/asf/logging-log4j-transform.git

commit 8161b72fc51fe4cb419e70c7d61f7ebf2d749232
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Mon Apr 1 12:27:19 2024 +0200

    Move code generation to `log4j-codegen` artifact
---
 log4j-codegen/dependency-reduced-pom.xml           | 218 +++++++++++++++++++++
 log4j-codegen/pom.xml                              | 164 ++++++++++++++++
 .../log4j/codegen}/BasicCommandLineArguments.java  |   6 +-
 .../log4j/codegen}/CustomLoggerGenerator.java      |   2 +-
 .../log4j/codegen}/ExtendedLoggerGenerator.java    |   2 +-
 .../apache/logging/log4j/codegen}/Generate.java    |   2 +-
 .../logging/log4j/codegen}/package-info.java       |   2 +-
 .../log4j/codegen}/picocli/CommandLine.java        |  14 +-
 .../log4j/codegen}/GenerateCustomLoggerTest.java   |  53 +++--
 .../log4j/codegen}/GenerateExtendedLoggerTest.java |  58 +++---
 pom.xml                                            |   7 +
 11 files changed, 462 insertions(+), 66 deletions(-)

diff --git a/log4j-codegen/dependency-reduced-pom.xml b/log4j-codegen/dependency-reduced-pom.xml
new file mode 100644
index 0000000..912b23b
--- /dev/null
+++ b/log4j-codegen/dependency-reduced-pom.xml
@@ -0,0 +1,218 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <artifactId>log4j-transform-parent</artifactId>
+    <groupId>org.apache.logging.log4j</groupId>
+    <version>0.2.0-SNAPSHOT</version>
+    <relativePath>../log4j-transform-parent/pom.xml</relativePath>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.logging.log4j</groupId>
+  <artifactId>log4j-codegen</artifactId>
+  <name>Apache Log4j Code generator</name>
+  <version>0.2.0-SNAPSHOT</version>
+  <description>Generates wrappers for Log4j code loggers.</description>
+  <licenses>
+    <license>
+      <name>Apache-2.0</name>
+      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <annotationProcessorPaths>
+            <path>
+              <groupId>info.picocli</groupId>
+              <artifactId>picocli-codegen</artifactId>
+              <version>${picocli.version}</version>
+            </path>
+          </annotationProcessorPaths>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>${maven-shade-plugin.version}</version>
+        <executions>
+          <execution>
+            <id>shade-jar-with-dependencies</id>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <transformers>
+                <transformer />
+                <transformer />
+                <transformer>
+                  <manifestEntries>
+                    <Multi-Release>true</Multi-Release>
+                  </manifestEntries>
+                </transformer>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-transform-maven-shade-plugin-extensions</artifactId>
+            <version>${project.version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.annotation.bundle</artifactId>
+      <version>2.0.0</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.annotation.versioning</artifactId>
+      <version>1.1.2</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.github.spotbugs</groupId>
+      <artifactId>spotbugs-annotations</artifactId>
+      <version>4.8.3</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api-test</artifactId>
+      <version>2.24.0-SNAPSHOT</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <artifactId>commons-lang3</artifactId>
+          <groupId>org.apache.commons</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>hamcrest</artifactId>
+          <groupId>org.hamcrest</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>junit</artifactId>
+          <groupId>junit</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>junit-pioneer</artifactId>
+          <groupId>org.junit-pioneer</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>junit-platform-commons</artifactId>
+          <groupId>org.junit.platform</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>maven-core</artifactId>
+          <groupId>org.apache.maven</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>maven-model</artifactId>
+          <groupId>org.apache.maven</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>plexus-utils</artifactId>
+          <groupId>org.codehaus.plexus</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>mockito-core</artifactId>
+          <groupId>org.mockito</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core-test</artifactId>
+      <version>3.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <artifactId>log4j-core</artifactId>
+          <groupId>org.apache.logging.log4j</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>log4j-plugins</artifactId>
+          <groupId>org.apache.logging.log4j</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>log4j-plugins-test</artifactId>
+          <groupId>org.apache.logging.log4j</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>assertj-core</artifactId>
+          <groupId>org.assertj</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>junit-jupiter-engine</artifactId>
+          <groupId>org.junit.jupiter</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>junit-jupiter-migrationsupport</artifactId>
+          <groupId>org.junit.jupiter</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>junit-jupiter-params</artifactId>
+          <groupId>org.junit.jupiter</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>junit-vintage-engine</artifactId>
+          <groupId>org.junit.vintage</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>hamcrest</artifactId>
+          <groupId>org.hamcrest</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>5.10.2</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <artifactId>opentest4j</artifactId>
+          <groupId>org.opentest4j</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>apiguardian-api</artifactId>
+          <groupId>org.apiguardian</groupId>
+        </exclusion>
+        <exclusion>
+          <artifactId>junit-platform-commons</artifactId>
+          <groupId>org.junit.platform</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-bom</artifactId>
+        <version>${log4j.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>info.picocli</groupId>
+        <artifactId>picocli</artifactId>
+        <version>${picocli.version}</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  <properties>
+    <picocli.version>4.7.5</picocli.version>
+    <maven-shade-plugin.version>3.4.1</maven-shade-plugin.version>
+    <log4j.version>3.0.0-SNAPSHOT</log4j.version>
+    <Main-Class>org.apache.logging.log4j.codegen.Generate</Main-Class>
+  </properties>
+</project>
diff --git a/log4j-codegen/pom.xml b/log4j-codegen/pom.xml
new file mode 100644
index 0000000..81bb7c5
--- /dev/null
+++ b/log4j-codegen/pom.xml
@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j-transform-parent</artifactId>
+    <version>${revision}</version>
+    <relativePath>../log4j-transform-parent</relativePath>
+  </parent>
+
+  <artifactId>log4j-codegen</artifactId>
+  <name>Apache Log4j Code generator</name>
+  <description>Generates wrappers for Log4j code loggers.</description>
+
+  <properties>
+    <Main-Class>org.apache.logging.log4j.codegen.Generate</Main-Class>
+
+    <!-- Plugin versions -->
+    <maven-shade-plugin.version>3.4.1</maven-shade-plugin.version>
+
+    <!-- Dependencies -->
+    <log4j.version>3.0.0-SNAPSHOT</log4j.version>
+    <picocli.version>4.7.5</picocli.version>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-bom</artifactId>
+        <version>${log4j.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+
+      <dependency>
+        <groupId>info.picocli</groupId>
+        <artifactId>picocli</artifactId>
+        <version>${picocli.version}</version>
+      </dependency>
+
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.annotation.bundle</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.annotation.versioning</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>com.github.spotbugs</groupId>
+      <artifactId>spotbugs-annotations</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>info.picocli</groupId>
+      <artifactId>picocli</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <annotationProcessorPaths combine.children="append">
+            <path>
+              <groupId>info.picocli</groupId>
+              <artifactId>picocli-codegen</artifactId>
+              <version>${picocli.version}</version>
+            </path>
+          </annotationProcessorPaths>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>${maven-shade-plugin.version}</version>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-transform-maven-shade-plugin-extensions</artifactId>
+            <version>${project.version}</version>
+          </dependency>
+        </dependencies>
+        <executions>
+          <execution>
+            <id>shade-jar-with-dependencies</id>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <transformers>
+                <transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer" />
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                  <manifestEntries>
+                    <Multi-Release>true</Multi-Release>
+                  </manifestEntries>
+                </transformer>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+
+  </build>
+
+</project>
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/BasicCommandLineArguments.java b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/BasicCommandLineArguments.java
similarity index 89%
rename from log4j-core/src/main/java/org/apache/logging/log4j/core/tools/BasicCommandLineArguments.java
rename to log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/BasicCommandLineArguments.java
index bacc03f..2c4666b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/BasicCommandLineArguments.java
+++ b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/BasicCommandLineArguments.java
@@ -14,13 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.log4j.core.tools;
+package org.apache.logging.log4j.codegen;
 
-import org.apache.logging.log4j.core.tools.picocli.CommandLine.Option;
+import org.apache.logging.log4j.codegen.picocli.CommandLine;
 
 public class BasicCommandLineArguments {
 
-    @Option(
+    @CommandLine.Option(
             names = {"--help", "-?", "-h"},
             usageHelp = true,
             description = "Prints this help and exits.")
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/CustomLoggerGenerator.java b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/CustomLoggerGenerator.java
similarity index 96%
rename from log4j-core/src/main/java/org/apache/logging/log4j/core/tools/CustomLoggerGenerator.java
rename to log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/CustomLoggerGenerator.java
index 8f61116..8f94d92 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/CustomLoggerGenerator.java
+++ b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/CustomLoggerGenerator.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.log4j.core.tools;
+package org.apache.logging.log4j.codegen;
 
 /**
  * Wrapper around {@link Generate.CustomLogger}.
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/ExtendedLoggerGenerator.java b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/ExtendedLoggerGenerator.java
similarity index 96%
rename from log4j-core/src/main/java/org/apache/logging/log4j/core/tools/ExtendedLoggerGenerator.java
rename to log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/ExtendedLoggerGenerator.java
index 339f9cc..944edfb 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/ExtendedLoggerGenerator.java
+++ b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/ExtendedLoggerGenerator.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.log4j.core.tools;
+package org.apache.logging.log4j.codegen;
 
 /**
  * Wrapper around {@link Generate.ExtendedLogger}.
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/Generate.java
similarity index 99%
rename from log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
rename to log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/Generate.java
index 5c3d34e..ee7156d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
+++ b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/Generate.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.log4j.core.tools;
+package org.apache.logging.log4j.codegen;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.PrintStream;
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/package-info.java b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/package-info.java
similarity index 95%
rename from log4j-core/src/main/java/org/apache/logging/log4j/core/tools/package-info.java
rename to log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/package-info.java
index 8cbd2eb..028b41b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/package-info.java
+++ b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/package-info.java
@@ -19,7 +19,7 @@
  */
 @Export
 @Version("2.20.1")
-package org.apache.logging.log4j.core.tools;
+package org.apache.logging.log4j.codegen;
 
 import org.osgi.annotation.bundle.Export;
 import org.osgi.annotation.versioning.Version;
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/picocli/CommandLine.java b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/picocli/CommandLine.java
similarity index 99%
rename from log4j-core/src/main/java/org/apache/logging/log4j/core/tools/picocli/CommandLine.java
rename to log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/picocli/CommandLine.java
index 37b5b46..fd7a29f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/picocli/CommandLine.java
+++ b/log4j-codegen/src/main/java/org/apache/logging/log4j/codegen/picocli/CommandLine.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.log4j.core.tools.picocli;
+package org.apache.logging.log4j.codegen.picocli;
 
-import static org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Column.Overflow.SPAN;
-import static org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Column.Overflow.TRUNCATE;
-import static org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Column.Overflow.WRAP;
+import static org.apache.logging.log4j.codegen.picocli.CommandLine.Help.Column.Overflow.SPAN;
+import static org.apache.logging.log4j.codegen.picocli.CommandLine.Help.Column.Overflow.TRUNCATE;
+import static org.apache.logging.log4j.codegen.picocli.CommandLine.Help.Column.Overflow.WRAP;
 import static org.apache.logging.log4j.util.Strings.toRootLowerCase;
 import static org.apache.logging.log4j.util.Strings.toRootUpperCase;
 
@@ -70,9 +70,9 @@ import java.util.TreeSet;
 import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.regex.Pattern;
-import org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Ansi.IStyle;
-import org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Ansi.Style;
-import org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Ansi.Text;
+import org.apache.logging.log4j.codegen.picocli.CommandLine.Help.Ansi.IStyle;
+import org.apache.logging.log4j.codegen.picocli.CommandLine.Help.Ansi.Style;
+import org.apache.logging.log4j.codegen.picocli.CommandLine.Help.Ansi.Text;
 
 /**
  * <p>
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java b/log4j-codegen/src/test/java/org/apache/logging/log4j/codegen/GenerateCustomLoggerTest.java
similarity index 85%
rename from log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java
rename to log4j-codegen/src/test/java/org/apache/logging/log4j/codegen/GenerateCustomLoggerTest.java
index 5932d11..d739c33 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java
+++ b/log4j-codegen/src/test/java/org/apache/logging/log4j/codegen/GenerateCustomLoggerTest.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.log4j.core.tools;
+package org.apache.logging.log4j.codegen;
 
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -25,17 +25,8 @@ import java.io.FileOutputStream;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticCollector;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
+import java.util.*;
+import javax.tools.*;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.core.test.TestConstants;
@@ -77,9 +68,12 @@ public class GenerateCustomLoggerTest {
         final String CLASSNAME = "org.apache.logging.log4j.core.MyCustomLogger";
 
         // generate custom logger source
-        final List<String> values = Arrays.asList("DEFCON1=350 DEFCON2=450 DEFCON3=550".split(" "));
-        final List<Generate.LevelInfo> levels = Generate.LevelInfo.parse(values, Generate.CustomLogger.class);
-        final String src = Generate.generateSource(CLASSNAME, levels, Generate.Type.CUSTOM);
+        final List<String> values = Arrays.asList("DEFCON1=351 DEFCON2=451 DEFCON3=551".split(" "));
+        final List<org.apache.logging.log4j.codegen.Generate.LevelInfo> levels =
+                org.apache.logging.log4j.codegen.Generate.LevelInfo.parse(
+                        values, org.apache.logging.log4j.codegen.Generate.CustomLogger.class);
+        final String src =
+                org.apache.logging.log4j.codegen.Generate.generateSource(CLASSNAME, levels, Generate.Type.CUSTOM);
         final File f = new File(TEST_SOURCE);
         f.getParentFile().mkdirs();
         try (final FileOutputStream out = new FileOutputStream(f)) {
@@ -163,19 +157,24 @@ public class GenerateCustomLoggerTest {
             });
         }
 
-        // now see if it actually works...
-        final Method create = cls.getDeclaredMethod("create", String.class);
-        final Object customLogger = create.invoke(null, "X.Y.Z");
-        int n = 0;
-        for (final String name : logMethods) {
-            final Method method = cls.getDeclaredMethod(name, String.class);
-            method.invoke(customLogger, "This is message " + n++);
-        }
-
         final TestLogger underlying = (TestLogger) LogManager.getLogger("X.Y.Z");
-        final List<String> lines = underlying.getEntries();
-        for (int i = 0; i < lines.size(); i++) {
-            assertEquals(" " + levels.get(i).name + " This is message " + i, lines.get(i));
+
+        try {
+            // now see if it actually works...
+            final Method create = cls.getDeclaredMethod("create", String.class);
+            final Object customLogger = create.invoke(null, "X.Y.Z");
+            int n = 0;
+            for (final String name : logMethods) {
+                final Method method = cls.getDeclaredMethod(name, String.class);
+                method.invoke(customLogger, "This is message " + n++);
+            }
+
+            final List<String> lines = underlying.getEntries();
+            for (int i = 0; i < lines.size(); i++) {
+                assertEquals(" " + levels.get(i).name + " This is message " + i, lines.get(i));
+            }
+        } finally {
+            underlying.getEntries().clear();
         }
     }
 }
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java b/log4j-codegen/src/test/java/org/apache/logging/log4j/codegen/GenerateExtendedLoggerTest.java
similarity index 83%
rename from log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java
rename to log4j-codegen/src/test/java/org/apache/logging/log4j/codegen/GenerateExtendedLoggerTest.java
index cb8f49a..0d1ff06 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java
+++ b/log4j-codegen/src/test/java/org/apache/logging/log4j/codegen/GenerateExtendedLoggerTest.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.logging.log4j.core.tools;
+package org.apache.logging.log4j.codegen;
 
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -79,8 +79,11 @@ public class GenerateExtendedLoggerTest {
 
         // generate custom logger source
         final List<String> values = Arrays.asList("DIAG=350 NOTICE=450 VERBOSE=550".split(" "));
-        final List<Generate.LevelInfo> levels = Generate.LevelInfo.parse(values, Generate.ExtendedLogger.class);
-        final String src = Generate.generateSource(CLASSNAME, levels, Generate.Type.EXTEND);
+        final List<org.apache.logging.log4j.codegen.Generate.LevelInfo> levels =
+                org.apache.logging.log4j.codegen.Generate.LevelInfo.parse(
+                        values, org.apache.logging.log4j.codegen.Generate.ExtendedLogger.class);
+        final String src =
+                org.apache.logging.log4j.codegen.Generate.generateSource(CLASSNAME, levels, Generate.Type.EXTEND);
         final File f = new File(TEST_SOURCE);
         f.getParentFile().mkdirs();
         try (final FileOutputStream out = new FileOutputStream(f)) {
@@ -172,29 +175,34 @@ public class GenerateExtendedLoggerTest {
             method.invoke(extendedLogger, "This is message " + n++);
         }
 
-        // This logger extends o.a.l.log4j.spi.ExtendedLogger,
-        // so all the standard logging methods can be used as well
-        final ExtendedLogger logger = (ExtendedLogger) extendedLogger;
-        logger.trace("trace message");
-        logger.debug("debug message");
-        logger.info("info message");
-        logger.warn("warn message");
-        logger.error("error message");
-        logger.fatal("fatal message");
-
         final TestLogger underlying = (TestLogger) LogManager.getLogger("X.Y.Z");
-        final List<String> lines = underlying.getEntries();
-        for (int i = 0; i < lines.size() - 6; i++) {
-            assertEquals(" " + levels.get(i).name + " This is message " + i, lines.get(i));
-        }
 
-        // test that the standard logging methods still work
-        int i = lines.size() - 6;
-        assertEquals(" TRACE trace message", lines.get(i++));
-        assertEquals(" DEBUG debug message", lines.get(i++));
-        assertEquals(" INFO info message", lines.get(i++));
-        assertEquals(" WARN warn message", lines.get(i++));
-        assertEquals(" ERROR error message", lines.get(i++));
-        assertEquals(" FATAL fatal message", lines.get(i++));
+        try {
+            // This logger extends o.a.l.log4j.spi.ExtendedLogger,
+            // so all the standard logging methods can be used as well
+            final ExtendedLogger logger = (ExtendedLogger) extendedLogger;
+            logger.trace("trace message");
+            logger.debug("debug message");
+            logger.info("info message");
+            logger.warn("warn message");
+            logger.error("error message");
+            logger.fatal("fatal message");
+
+            final List<String> lines = underlying.getEntries();
+            for (int i = 0; i < lines.size() - 6; i++) {
+                assertEquals(" " + levels.get(i).name + " This is message " + i, lines.get(i));
+            }
+
+            // test that the standard logging methods still work
+            int i = lines.size() - 6;
+            assertEquals(" TRACE trace message", lines.get(i++));
+            assertEquals(" DEBUG debug message", lines.get(i++));
+            assertEquals(" INFO info message", lines.get(i++));
+            assertEquals(" WARN warn message", lines.get(i++));
+            assertEquals(" ERROR error message", lines.get(i++));
+            assertEquals(" FATAL fatal message", lines.get(i++));
+        } finally {
+            underlying.getEntries().clear();
+        }
     }
 }
diff --git a/pom.xml b/pom.xml
index e28d5d9..dca56a5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -73,6 +73,7 @@
     <module>log4j-transform-parent</module>
 
     <!-- Modules here must have a corresponding entry in `dependencyManagement > dependencies` block below! -->
+    <module>log4j-codegen</module>
     <module>log4j-transform-maven-plugin</module>
     <module>log4j-transform-maven-shade-plugin-extensions</module>
     <module>log4j-weaver</module>
@@ -116,6 +117,12 @@
   <dependencyManagement>
     <dependencies>
 
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-codegen</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+
       <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-transform-maven-plugin</artifactId>