Created
May 6, 2019 06:46
-
-
Save krast/a3607326b051abcb915fbe7340cb24e9 to your computer and use it in GitHub Desktop.
Lombok delombok 查看lombok生成的源码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
参考链接 | |
======== | |
https://projectlombok.org/features/delombok | |
https://awhitford.github.io/lombok.maven/lombok-maven-plugin/usage.html | |
为什么需要查看lombok生成的源码? | |
=============================== | |
主要原因有二: | |
- 有助于理解lombok的under the hood工作. | |
- 便于源码与非IDE继承, 例如Google Widget Toolkit, 生成javadoc, 或者接入sourcetrail等源码阅读工具; | |
原理 | |
==== | |
复制整个文件夹, 递归解析所有的java文件中与lombok转换相关的部分. | |
运行指令 | |
======== | |
处理整个工程: | |
java -jar lombok.jar delombok src -d src-delomboked | |
处理单个代码文件: | |
java -jar lombok.jar delombok -p MyJavaFile.java | |
使用实例: maven联合delombok, 生成javadoc | |
======================================== | |
首先需要安装lombok-maven-plugin, 详见https://github.com/awhitford/lombok.maven, 该插件会在generate-sources阶段执行delombok操作. | |
Place the java source code with lombok annotations in src/main/lombok (instead of src/main/java). During the build process, the src/main/lombok code will be delomboked and the generated java code ends up in target/generated-sources/delombok. The delomboked code is compiled and analysed together with the src/main/java code. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment