简体   繁体   中英

maven build fails for java 9 when java 11 is installed

I'm trying to build the log4j package from source:

$ wget https://github.com/apache/logging-log4j2/archive/refs/tags/rel/2.14.1.tar.gz
$ tar -xf 2.14.1.tar.gz
$ cd logging-log4j2-rel-2.14.1/log4j-core
$ /apache-maven-3.8.4/bin/mvn compile 1>./temp.txt
$ grep "\[ERROR\] Failed.*java9.*" ./temp.txt | sed "s/: org/:\norg/g"
[ERROR] Failed to execute goal on project log4j-core: Could not resolve dependencies for project org.apache.logging.log4j:log4j-core:jar:2.14.1:
org.apache.logging.log4j:log4j-core-java9:zip:2.14.1 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

This is a bit weird because my java version is 11, what am I missing?

$ java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM