IntelliJ IDEA gradle项目设置 [英] IntelliJ IDEA gradle project setup

查看:706
本文介绍了IntelliJ IDEA gradle项目设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IntelliJ IDEA 12.1.3中开始新Gradle项目的最佳步骤是什么?

What is the best procedure for beginning a new Gradle project in IntelliJ IDEA 12.1.3?

我创建了一个骨架 build.gradle 带有idea插件的文件生成项目文件:

I created a skeleton build.gradle file with the idea plugin to generate the project files:

apply plugin: 'java'
apply plugin: 'idea'

task wrapper(type: Wrapper) {
    gradleVersion = '1.6'
}

当我打开新项目时,IntelliJ抱怨没有为模块配置 Groovy SDK

When I open the new project IntelliJ complains that the Groovy SDK is not configured for module:

配置Groovy SDK后,我在构建文件中遇到了Java检查问题:

After configuring the Groovy SDK I get Java inspection issues in the build file:

我在做错了什么,或者在IDEA中基于Gradle的项目是否正常?我应该禁用检查吗?

Am I doing something wrong or is this normal for a Gradle based project in IDEA? Should I just disable inspection?

更新

我能够导入骨架项目,IDEA会自动正确配置所有内容。但是我仍然在 build.gradle 中收到Java检查错误,如上所示。

I was able to import a skeleton project and IDEA automatically configured everything properly. However I am still receiving Java inspection errors in build.gradle as shown above.

推荐答案

如果您使用Gradle的 idea 任务来生成项目文件,这是正常的,因为没有办法告诉IDEA构建脚本本身的类路径是什么。如果您改为使用IDEA的Gradle集成(从Gradle模型导入),则此问题不存在。

If you use Gradle's idea task to generate project files, this is normal, as there is no way to tell IDEA what the class path of the build script itself is. If you instead use IDEA's Gradle integration ("Import from Gradle model"), this problem doesn't exist.

这篇关于IntelliJ IDEA gradle项目设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆