Until recently, the build process of log4j-core depends on the build process of a companion log4j-core-java9 module.
This multi-module build approach was introduced in this issue and the changes performed are described in this commit.
In a future version of the library these dependencies will be removed as described in this issue precisely to avoid potential dependency problems. The issue provides more information about was it going on:
Log4j API and Log4j Core have to build the Java 9 classes in one
Maven module and then copy them into the "normal" module. The Java
9 projects are not deployed during a release. The pom.xml files
were specifying both as provided dependencies. When the enforcer
plugin sees this it is trying to resolve them - sometimes - and
fails. It seems these don't need to be declared as dependencies
because they are configured into the dependency plugin. So the
dependencies should be removed from the pom files.
If you need to build the code from an older version from source, according to the changes introduced in the aforementioned commit, you first need to assembly log4j-core-java9 and then use the dependency in the build process of log4j-core itself.
In a nutshell, try the following.
First, log4j2 uses toolchains in its build process, so for JDK 11 you may need to provide an entry in ~/.m2/toolchains.xml file like the following:
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!-- other definitions -->
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
</provides>
<configuration>
<jdkHome>path/to/the/jdk (/opt/java/openjdk, for instance)</jdkHome>
</configuration>
</toolchain>
</toolchains>
You can find different toolchain configuration examples in the repository library.
Now, run the following commands from the directory in which you unpacked the library.
Install log4j2-api-java9:
cd log4j2-api-java9
../mvnw clean install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
Install log4j2-api:
cd ../log4j2-api
../mvnw clean install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
Install log4j-core-java9:
cd ../log4j-core-java9/
../mvnw clean install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
Finally, package log4j-core:
cd ../log4j-core
../mvnw clean package -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
Please, be aware that this build process could generate a lot of artifacts that will be installed in your Maven local repository, and that may conflict with versions of the library downloaded from the Maven remote repository. Consider using for this process a temporary docker container, for example:
docker run -it --entrypoint /bin/bash adoptopenjdk/openjdk11:latest
and run these different commands within it.