Java 如何从 Mac bash 的命令行运行 Gradle

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27094492/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 03:47:54  来源:igfitidea点击:

How to run Gradle from the command line on Mac bash

javamacosbashgradle

提问by Barodapride

I have a very simple question. I am brand new to Mac and I am trying to get my Java project moved over to my new Mac. The project has a Gradlew file that I thought I could run from the command line to build and run on any machine. When I do gradlew from the command line (in the location of the gradlew file) it says gradlew not found. Am I missing something on how to run a command from a bash shell?

我有一个非常简单的问题。我是 Mac 的新手,我正在尝试将我的 Java 项目转移到我的新 Mac。该项目有一个 Gradlew 文件,我认为我可以从命令行运行它以在任何机器上构建和运行。当我从命令行(在 gradlew 文件的位置)执行 gradlew 时,它说找不到 gradlew。我是否缺少有关如何从 bash shell 运行命令的信息?

采纳答案by Alex Filatov

./gradlew

./gradlew

Your directory with gradlew is not included in the PATH, so you must specify path to the gradlew. .means "current directory".

您的 gradlew 目录不包含在 PATH 中,因此您必须指定 gradlew 的路径。 .表示“当前目录”。

回答by Evin1_

Also, if you don't have the gradlewfile in your current directory:

另外,如果当前目录中没有gradlew文件:

You can install gradle with homebrewwith the following command:

您可以使用以下命令使用自制软件安装 gradle :

$ brew install gradle

As mentioned in this answer. Then, you are not going to need to include it in your path (homebrew will take care of that) and you can just run (from any directory):

正如这个答案中提到的。然后,您不需要将它包含在您的路径中(自制软件会处理它),您只需运行(从任何目录):

$ gradle test