Java 如何在 Intellij IDEA 中使用 gradle run?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38665255/
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
How to use gradle run with Intellij IDEA?
提问by Gatonito
I have the following build.gradle
file:
我有以下build.gradle
文件:
apply plugin:'application'
mainClassName = "MyMain"
allprojects {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
repositories {
mavenCentral()
}
dependencies {
compile 'org.jsoup:jsoup:1.8.3'
}
So when I do gradle run
it works perfectly, it uses jsoup and so.
所以当我做的时候gradle run
它工作得很好,它使用 jsoup 等等。
Now, I've imported this project at my Intellij Idea IDE, I created a gradle build run/debug configuration, so when I press the green arrow 'run', it's building the application, but not running it, so I guess it's executing gradle build
.
现在,我已经在我的 Intellij Idea IDE 中导入了这个项目,我创建了一个 gradle 构建运行/调试配置,所以当我按下绿色箭头“运行”时,它正在构建应用程序,但没有运行它,所以我猜它正在执行gradle build
.
I've searched for an way to run the application, and the Intellij Idea says that I must create a new Application run/debug configuration. I did it, told where my main class was, but when I click run, it tries to make the source code, and claims that it can't find Jsoup for compiling.
我已经搜索了一种运行应用程序的方法,Intellij Idea 说我必须创建一个新的应用程序运行/调试配置。我做到了,告诉我我的主类在哪里,但是当我点击运行时,它试图制作源代码,并声称它找不到用于编译的 Jsoup。
How can I mimic gradle run
in intellij idea's IDE?
如何gradle run
在intellij idea的IDE中模仿?
回答by Matt R
Open the gradle window in Intellij. View->Tool Windows->Gradle.
在 Intellij 中打开 gradle 窗口。查看->工具窗口->Gradle。
On the right hand side you will see a list of all your gradle tasks. Double click to run or right click and assign a shortcut to any of them.
在右侧,您将看到所有 gradle 任务的列表。双击运行或右键单击并为其中任何一个分配快捷方式。
回答by Grasshopper
Look for the Gradle Tool Window. The rest is self-explanatory :)
寻找Gradle 工具窗口。其余的不言自明:)
回答by Alexiy
Do not forget to click "Refresh all Gradle projects" in that tool window each time you change the build script.
每次更改构建脚本时,不要忘记在该工具窗口中单击“刷新所有 Gradle 项目”。
回答by Radek Riedel
You need to delegate IDE build/run actions to Gradle
您需要将 IDE 构建/运行操作委托给 Gradle