gradle问题总结
一、报错
FAILURE: Build failed with an exception.
- Where:
Build file 'D:\Codes\spring-framework\build.gradle' line: 9 - What went wrong:
An exception occurred applying plugin request [id: 'com.gradle.build-scan', version: '3.2']
Failed to apply plugin [id 'com.gradle.build-scan']
The build scan plugin is not compatible with Gradle 6.0 and later.
Please use the Gradle Enterprise plugin instead.
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. - Get more help at https://help.gradle.org
BUILD FAILED in 10s
原因是gradle版本太高了,具体参考:https://docs.gradle.com/enterprise/compatibility/#build_scan_plugin
版本下载网站:http://services.gradle.org/distributions/
二、gradle构建乱码_Gradle项目中文乱码的解决办法
网上搜索了下都是在build.gradle中最后加入
tasks.withType(JavaCompile) {
options.encoding = “UTF-8”
}
但是试过构建时报错,无法识别
- What went wrong:
Could not compile build file 'D:\Codes\spring-framework\build.gradle'.
startup failed:
build file 'D:\Codes\spring-framework\build.gradle': 414: expecting '}', found '”' @ line 414, column 28.
options.encoding = “UTF-8”
1 error
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. - Get more help at https://help.gradle.org
后来使用环境变量解决了这个问题。在Windows下,新建GRADLE_OPTS环境变量,值为-Dfile.encoding=utf-8。然后新开一个终端窗口再次使用gradle命令,就会发现这下Gradle已经可以正确识别编码了。