首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >分级安装提供不同的分级版本

分级安装提供不同的分级版本
EN

Stack Overflow用户
提问于 2021-06-17 10:35:57
回答 1查看 280关注 0票数 0

作为一个新用户,我试图在我的mac上安装gradle-5.6.4,但是当我检查gradle版本时,它显示了Gradle 7.0。是否有任何东西可以切换或更正版本控制到gradle。

代码语言:javascript
复制
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中,我添加了以下内容:

代码语言:javascript
复制
export GRADLE_HOME=/Users/user/Downloads/gradle-5.6.4
export PATH=$PATH:$GRADLE_HOME/bin

还有一个.gradle文件夹,它生成并显示文件夹中的> .gradle.caches>7.0,如果它指向Gradle 7.0。我已经尝试删除这也,但得到自动生成。

EN

回答 1

Stack Overflow用户

发布于 2021-12-05 15:55:42

运行这些命令时,您不在项目目录中。

从项目文件夹中运行gradle命令,而不是在Gradle安装的bin文件夹中运行。

检查PATH环境变量的值,看看其他Gradle安装可能已经是其中的一部分。

代码语言:javascript
复制
echo $PATH

我相当肯定,您会发现gradle 7.0的Gradle命令已经在路上了。您可以编辑路径或提供调用Gradle 5.6.4的完整路径,但最好的方法是使用项目中的Gradle包装器强制Gradle版本达到对项目有用的效果。

请注意,“gradlew”不是Gradle的一部分,它是为一些基于Gradle的项目添加的包装脚本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68017640

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档