在IntelliJ IDEA中附加Gradle源 [英] Attaching Gradle sources in IntelliJ IDEA

查看:153
本文介绍了在IntelliJ IDEA中附加Gradle源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用默认的gradle包装器和创建目录选项在IntelliJ中创建Gradle项目后,我会看到使用 build.gradle 文件创建了项目结构.

Once after I create a Gradle project in IntelliJ using the default gradle wrapper and create directories option I see the project structure gets created with build.gradle file.

IntelliJ提示我您可以配置Gradle包装器以对源使用分发.它将向IDE提供Gradle API/DSL文档"-但是即使点击确定,应用建议"后,我也无法附加来源.Gradle项目正在刷新,但未附加源.

IntelliJ tips me to "You can configure Gradle wrapper to use distribution with sources. It will provide IDE with Gradle API/DSL documentation" - but I am not able to attach the sources even after clicking "Ok, apply suggestion". The Gradle project is getting refreshed but the sources are not attached.

我们正在使用Nexus存储库.

We are using a Nexus repository.

推荐答案

要改善@ anon58192932的答案,您只能使用Wrapper任务的gradleVersion和distributionType字段,而无需手动创建distributionUrl,因为您更容易出错可以在一个地方更改gradle版本,但不能在另一个地方更改.

To improve on @anon58192932 answer you can use only gradleVersion and distributionType fields of Wrapper task and don't need to manually create distributionUrl which is more error prone since you could change gradle version in one place, but not in the other.

task wrapper(type: Wrapper) {
    gradleVersion = '4.2'
    distributionType = Wrapper.DistributionType.ALL
}

@editgradle 4.8+将产生上述错误.改用

@edit gradle 4.8+ will produce error for above. Use instead

wrapper {
    gradleVersion = '4.2'
    distributionType = Wrapper.DistributionType.ALL
}

这篇关于在IntelliJ IDEA中附加Gradle源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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