【发布时间】:2021-09-02 03:46:12
【问题描述】:
作为一个新用户,我试图在我的 Mac 上安装 gradle-5.6.4,但是当我检查 gradle 版本时,它显示 Gradle 7.0。有什么可以切换或更正版本控制到 gradle。
machine1:~ user$ cd /Users/user/Downloads/gradle-5.6.4/bin
machine1:bin user$ gradle
Welcome to Gradle 7.0!
Here are the highlights of this release:
- File system watching enabled by default
- Support for running with and building Java 16 projects
- Dependency catalog feature preview
For more details see https://docs.gradle.org/7.0/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :help
Welcome to Gradle 7.0.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
To see more detail about a task, run gradle help --task <task>
For troubleshooting, visit https://help.gradle.org
BUILD SUCCESSFUL in 6s
1 actionable task: 1 executed
machine1:bin user$
machine1:bin user$ gradle wrapper --gradle-version 5.6.4
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
> Task :wrapper FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Some problems were found with the configuration of task ':wrapper' (type 'Wrapper').
- Type 'Wrapper' property 'jarFile' is not writable because '/Users/user/Downloads/gradle-5.6.4/bin/gradle/wrapper/gradle-wrapper.jar' ancestor '/Users/user/Downloads/gradle-5.6.4/bin/gradle' is not a directory.
Reason: Cannot write a file to a location pointing at a directory.
Possible solution: Configure 'jarFile' to point to a file, not a directory.
Please refer to https://docs.gradle.org/7.0/userguide/validation_problems.html#cannot_write_output for more details about this problem.
- Type 'Wrapper' property 'propertiesFile' is not writable because '/Users/user/Downloads/gradle-5.6.4/bin/gradle/wrapper/gradle-wrapper.properties' ancestor '/Users/user/Downloads/gradle-5.6.4/bin/gradle' is not a directory.
Reason: Cannot write a file to a location pointing at a directory.
Possible solution: Configure 'propertiesFile' to point to a file, not a directory.
Please refer to https://docs.gradle.org/7.0/userguide/validation_problems.html#cannot_write_output for more details about this problem.
* 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 5s
1 actionable task: 1 executed
machine1:bin user$
machine1:bin user$
machine1:bin user$ ./gradlew build
-bash: ./gradlew: No such file or directory
machine1:bin user$ pwd
/Users/user/Downloads/gradle-5.6.4/bin
machine1:bin user$ ls
gradle gradle.bat settings.gradle
不确定 Gradle 7 是否被意外安装并覆盖到 gradle 5.6.4。不确定要遵循的正确步骤是什么。在我的 .bash_profile 中,我添加了以下内容:
export GRADLE_HOME=/Users/user/Downloads/gradle-5.6.4
export PATH=$PATH:$GRADLE_HOME/bin
还有一个 .gradle 文件夹,它会生成并在文件夹中显示 > .gradle.caches>7.0,如果它指向 Gradle 7.0。我也尝试将其删除,但会自动生成。
【问题讨论】:
-
您将其添加到 PATH 环境变量的末尾,因此将在最后找到它。 PATH 中是否已经有另一个 Gradle 文件夹?