前言
创作开始时间:2021年3月15日14:56:28
如题。gradle项目运行时碰到这个问题:
> Task :gen.jdt:checkstyleMain FAILED
[ant:checkstyle] [ERROR] /xxx/gumtreediff/gen/jdt/JdtVisitor.java:101:9: Line contains a tab character. [FileTabCharacter]
[ant:checkstyle] [ERROR] /xxx/gumtreediff/gen/jdt/JdtVisitor.java:102:9: Line contains a tab character. [FileTabCharacter]
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':gen.jdt:checkstyleMain'.
> Checkstyle rule violations were found. See the report at: file:///xxx/gumtree/gen.jdt/build/reports/checkstyle/main.html
Checkstyle files with violations: 1
Checkstyle violations by severity: [error:2]
本文给出解决方案。
正文
第一步
我的项目是在eclipse中修改的,所以在eclipse中做下图修改:
上方菜单栏->Windows->Preferences->General->Editors->Text Editors-> Insert spaces for tabs
第二步
同样,在preferences的Java -> Formatter 栏新建一个 Formatter,(我命名成了dale_code_style),然后修改Indentation为spaces only
.然后确认,应用即可。如下图。
重新编译
此时终于没错误了。
小结
以上。参考文献一开始没找对,硬是没解决问题。
不过也学到了知识,从这篇博客:
- java编程规范之eclipse设置tab键为四个空格 原来不设置tab的后果会是这样,可能换一个文件编辑器,代码的缩进就全乱了。会给代码审查造成麻烦。(原来如此)
创作结束时间:2021年3月15日15:18:20