ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

跟风蹭热度编译个logging-log4j2包-jdk11

2021-12-10 22:33:45  阅读:1029  来源: 互联网

标签:core logging jdk11 api ERROR 2.15 log4j2 log4j


习惯先用jdk1.8打包编译,由于源码里有java9相关的模块,jdk8出错

log4j-core-java9
log4j-api-java9

报错

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (default) on project log4j-api-java9: Cannot find matching toolchain definitions for the following toolchain types:
[ERROR] jdk [ version='[9, )' ]
[ERROR] Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file.

单docker镜像里只有一个版本的jdk,准备环境要花点工夫,先试用用jdk11 打包

下载源码

Release log4j-2.15.0-rc2 · apache/logging-log4j2 (github.com)

apache/logging-log4j2 at log4j-2.15.0-rc2 (github.com)

编辑 logging-log4j2/toolchains-sample-linux.xml at log4j-2.15.0-rc2 · apache/logging-log4j2 (github.com)

**加速包下载...

mvn package -DskipTests=true

期间有出错

[INFO] Apache Log4j Spring Cloud Config Support ........... SKIPPED
[INFO] Apache Log4j Spring Cloud Config Client Support .... SKIPPED
[INFO] Apache Log4j Sample Configuration Service .......... SKIPPED
[INFO] Apache Log4j Spring Cloud Config Samples ........... SKIPPED
[INFO] Apache Log4j Spring Cloud Config Sample Application  SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  14.294 s
[INFO] Finished at: 2021-12-10T12:17:13Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project log4j-api: Compilation failure
[ERROR] /tmp/logging-log4j2-log4j-2.15.0-rc2/log4j-api/src/test/java/org/apache/logging/log4j/util/StackLocatorUtilTest.java:[25,18] error: cannot find symbol
[ERROR]   symbol:   class Reflection
[ERROR]   location: package sun.reflect
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :log4j-api

由于是在docker里用openjdk编译,jdk环境可能不完整,这是测试代码,不影响功能为快速编译,直接删除后继续

rm /tmp/logging-log4j2-log4j-2.15.0-rc2/log4j-api/src/test/java/org/apache/logging/log4j/util/StackLocatorUtilTest.java
mvn package -DskipTests=true

编译还是很耗时,不必要的模块较多,注释跳过即可

原始所有模块

  <modules>
    <module>log4j-api-java9</module>
    <module>log4j-api</module>
    <module>log4j-core-java9</module>
    <module>log4j-core</module>
    <module>log4j-layout-template-json</module>
    <module>log4j-core-its</module>
    <module>log4j-1.2-api</module>
    <module>log4j-slf4j-impl</module>
    <module>log4j-slf4j18-impl</module>
    <module>log4j-to-slf4j</module>
    <module>log4j-jcl</module>
    <module>log4j-flume-ng</module>
    <module>log4j-taglib</module>
    <module>log4j-jmx-gui</module>
    <module>log4j-samples</module>
    <module>log4j-bom</module>
    <module>log4j-jdbc-dbcp2</module>
    <module>log4j-jpa</module>
    <module>log4j-couchdb</module>
    <module>log4j-mongodb3</module>
    <module>log4j-mongodb4</module>
    <module>log4j-cassandra</module>
    <module>log4j-web</module>
    <module>log4j-jakarta-web</module>
    <module>log4j-perf</module>
    <module>log4j-iostreams</module>
    <module>log4j-jul</module>
    <module>log4j-jpl</module>
    <module>log4j-liquibase</module>
    <module>log4j-appserver</module>
    <module>log4j-osgi</module>
    <module>log4j-docker</module>
    <module>log4j-kubernetes</module>
    <module>log4j-spring-boot</module>
    <module>log4j-spring-cloud-config</module>
  </modules>

精简为

  <modules>
    <module>log4j-api-java9</module>
    <module>log4j-api</module>
    <module>log4j-core-java9</module>
    <module>log4j-core</module>
    <module>log4j-core-its</module>
    <module>log4j-1.2-api</module>
    <module>log4j-slf4j-impl</module>
    <module>log4j-slf4j18-impl</module>
    <module>log4j-to-slf4j</module>
  </modules>

应该还能再精简

最后只需要两个包

root@6f0c9dbb976b:/tmp/logging-log4j2-log4j-2.15.0-rc2# md5sum log4j-api/target/log4j-api-2.15.0.jar
62a0c20d6345a721f17611f88d5714c9  log4j-api/target/log4j-api-2.15.0.jar
root@6f0c9dbb976b:/tmp/logging-log4j2-log4j-2.15.0-rc2# md5sum log4j-core/target/log4j-core-2.15.0.jar
d6ebc62e68365231ec12e0a28f2b742c  log4j-core/target/log4j-core-2.15.0.jar

完成,准备用jdk9再试下

End

标签:core,logging,jdk11,api,ERROR,2.15,log4j2,log4j
来源: https://www.cnblogs.com/zihunqingxin/p/15674069.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[[email protected]]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有