如何在 Intellij IDEA 13.0.1 社区中创建基于 gradle 的 Java 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20648942/
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-13 03:20:49  来源:igfitidea点击:

How to create a gradle-based Java Project in Intellij IDEA 13.0.1 Community

javaintellij-ideagradle

提问by macemers

I want to start a empty project with Gradle in Intellij IDEA but it seems not so convenient as Eclipse does.

我想在 Intellij IDEA 中使用 Gradle 启动一个空项目,但它似乎不像 Eclipse 那样方便。

What I did is File->New Project->Gradle. And a project shows up but it's not completed (it has no src folder for example).

我所做的是 File->New Project->Gradle。并且显示了一个项目,但尚未完成(例如,它没有 src 文件夹)。

And I add apply plugin 'idea'in the build.gradle. When I refer to the All tasks in IntelliJ IDEA. There are no idea,cleanIdea,ideaProjectfor me to set up a IntelliJ IDEA.

apply plugin 'idea'在 build.gradle 中添加。当我参考 IntelliJ IDEA 中的所有任务时。我没有idea,cleanIdea,ideaProject设置 IntelliJ IDEA。

In Eclipse+Gradle plugin, just create a new gradle project and everything is ready.

在 Eclipse+Gradle 插件中,只需新建一个 gradle 项目就可以了。

I want to know how to do that in Intellij IDEA.

我想知道如何在 Intellij IDEA 中做到这一点。

Thanks

谢谢

采纳答案by kukido

When creating new Gradle project, select "Create directories for empty content roots automatically".

创建新的 Gradle 项目时,选择“自动为空内容根目录创建目录”。

New Gradle project wizard

新建 Gradle 项目向导

New project will have those directories.

新项目将具有这些目录。

Gradle project structure

Gradle项目结构

回答by DYS

In latest IntelliJ IDEA Community Edition(2018.1), there's no Create directories for empty content roots automaticallyoption available in New Projectdialog. But we can go to Preferences...->Build, Execution, Deployment->Gradleand check the underlined option in the screenshot below.

在最新的 IntelliJ IDEA 社区版(2018.1)中,对话框中没有Create directories for empty content roots automatically可用New Project选项。但是我们可以转到Preferences...-> Build, Execution, Deployment->Gradle并检查下面屏幕截图中带下划线的选项。

enter image description here

在此处输入图片说明