使用Gradle构建获取IntelliJ IDEA中的Gradle依赖关系 [英] Getting Gradle dependencies in IntelliJ IDEA using Gradle build

查看:1005
本文介绍了使用Gradle构建获取IntelliJ IDEA中的Gradle依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使从IntelliJ IDEA内部进行评分构建,也不会将相关性放到外部库文件夹中,因此这些类不会在编辑器中显示为建议,并且当我手动将它们添加为导入时,错误。



如何让IntelliJ自动将依赖项合并到我的 build.gradle 文件中,例如:



compile'c​​om.google.code.gson:gson:1.7.2

解决方案

您需要从Idea内将项目作为Gradle项目导入。当你添加一个依赖项时,你需要打开Gradle窗口并执行一次刷新。



或者使用以下代码从gradle中生成项目文件:

build.gradle:

 应用插件:'idea'

然后执行:

  $ gradle想法

如果您修改相关性,您需要重新运行上述内容。


Grade build, even from inside IntelliJ IDEA does not put the dependencies into the "External Libraries" folder, so these classes don't show up as suggestions in the editor and when I manually add them as an import there is a compile error.

How can I get IntelliJ to automatically incorporate the dependencies in my build.gradle file, for instance:

compile 'com.google.code.gson:gson:1.7.2

解决方案

You either need to import the project as a Gradle project from within Idea. When you add a dependency you need to open the Gradle window and perform a refresh.

Alternatively generate the project files from gradle with this:

build.gradle:

apply plugin: 'idea'

And then run:

$ gradle idea

If you modify the dependencies you will need to rerun the above again.

这篇关于使用Gradle构建获取IntelliJ IDEA中的Gradle依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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