在由Gradle下载的依赖关系罐上使用autosuggest [英] Using autosuggest on dependency jars that are downloaded by Gradle
问题描述
我对Gradle和IntelliJ很新颖,我试图理解它是如何工作的(因为我的项目使用了这个工具)。我使用HelloWorld类在Intellij IDEA中创建了一个简单的Java项目,并手动添加了gradle.build文件以及必要的依赖关系,如下所示:
apply plugin:'java'
apply plugin:'idea'
apply plugin:'application'
mainClassName ='main.java.test.HelloWorld'
依赖项{
compile'joda-time:joda-time:2.2'
}
仓库{
mavenLocal()
mavenCentral()
}
jar {
baseName ='gradle-test'
manifest {
属性'Main-Class':'main.java .test.HelloWorld'
}
}
任务包装器(类型:包装器){
gradleVersion ='2.2'
}
虽然我指定了joda时间依赖项,但我的IntelliJ项目并不知道这个库,因此我无法使用任何IntelliJ的自动提示功能,用于乔达时间库。
有人可以告诉我如何让IntelliJ自动开始识别下载的jar并允许我使用自动建议功能吗?
换句话说,
- 下载哪个依赖性jar文件?
- 如何让这些罐子自动包含在项目的
类路径中? [可以这么做吗?如果不是,您的建议是什么
?]
谢谢!
解决方案我使用Peter的建议来运行
gradle idea
并将项目导入到IntelliJ中,并且我能够开始使用auto - IntelliJ中的推荐功能。
谢谢
I'm pretty new to Gradle and IntelliJ and I'm trying to understand how it works [cos that's what my project uses]. I created a simple java project in Intellij IDEA with a HelloWorld class and manually added the gradle.build file along with the necessary dependencies as follows:
apply plugin: 'java' apply plugin: 'idea' apply plugin: 'application' mainClassName = 'main.java.test.HelloWorld' dependencies { compile 'joda-time:joda-time:2.2' } repositories { mavenLocal() mavenCentral() } jar { baseName = 'gradle-test' manifest { attributes 'Main-Class': 'main.java.test.HelloWorld' } } task wrapper(type: Wrapper) { gradleVersion = '2.2' }
While I specified the joda-time dependency, my IntelliJ project is unaware of this library and therefore I can't use of any of the autosuggest features of IntelliJ for the joda-time library.
Could someone give me information on how I can get IntelliJ to automatically start recognizing the downloaded jars and allow me to use the auto-suggest features?
In other words,- where are the dependency jars downloaded ?
- How can I have these jars to automatically be included in the class path of the project ? [Is it ok to do so ? If not, what would be your recommendation ?]
Thanks !
解决方案I used Peter's suggestion to run
gradle idea
and imported the project into IntelliJ and I was able to start using the auto-suggestion features in IntelliJ.Thanks
这篇关于在由Gradle下载的依赖关系罐上使用autosuggest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!