关于配置Gradle后执行gradle -v命令出现“BUILD FAILED”错误的解决办法

关于配置Gradle后执行gradle -v命令出现“BUILD FAILED”错误的解决办法

环境说明

  • 操作系统:Ubuntu16.10
  • Gradle版本:gradle4.4.1

错误日志

FAILURE: Build failed with an exception.

What went wrong:
Task ‘GRADLE_OPTS=->Dgradle.user.home=/usr/SoftwareEngineer/softwareInstallPlace/Apach/Gradl>e4/Gradle4/gradle441/gradle_cache’ not found in root project ‘foxcles’.
Try:
Run gradle tasks to get a list of available tasks. 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 0s

错误原因

gradle软件包中的bin目录下有一个gradle文件,用来配置gradle启动时的一下相关信息,具体的有时间在写一篇博客来说明。其中有一行
代码如下:
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
GRADLE_OPTS=-Dgradle.user.home=/usr/SoftwareEngineer/softwareInstallPlace/Apach/Gradle4/Gradle4/gradle441/gradle_cache

这行代码设置了gradle的缓存位置,因为本人的gradle是从公司的环境copy过来的,原来是:
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set GRADLE_OPTS='-Dgradle.user.home=I:XXXX\XXXX\XXXX\gradle_cache'

这导致gradle无法正确获得路径信息,所以一直报错。用vim或是gedit命令修改这个文件之后保存,在终端运行gradle -v,将出现以下说明,说明gradle
配置没有问题。

## PS
简单记录一下配置gradle的环境步骤:
1.打开profile文件 sudo gedit /etc/profile;
2.在末尾行添加
export GRADLE_HOME=/usr/SoftwareEngineer/softwareInstallPlace/Apach/Gradle4/Gradle4/gradle441
export PATH=$GRADLE_HOME/bin:$PATH

你可能感兴趣的:(错误笔记)