如何让 Intellij IDEA 使用并行和 gradle 构建缓存进行构建
Posted
技术标签:
【中文标题】如何让 Intellij IDEA 使用并行和 gradle 构建缓存进行构建【英文标题】:How to make Intellij IDEA use parallel and gradle build cache for building 【发布时间】:2020-02-12 08:22:28 【问题描述】:什么控制 Intellij IDEA IDE 构建/重建如何使用 gradle 构建缓存和并行选项?
我有 gradle 构建缓存设置,如果我通过 IDEA runConfiguration 运行 gradle,我会看到以下内容:
45s clean build --parallel -x test
34s build --parallel -x test
如果我单击锤子进行构建或选择构建:重建,我会看到 2 分 10 秒及以上的时间。
我如何启用缓存
在命令行和通过 runConfiguration,速度提升非常好。通过 Intellij 的锤子构建时,速度要慢得多
gradle.properties
# Enable gradle build cache
org.gradle.caching=true
gradle.cache.push=false
settings.gradle
ext.inJenkins = System.getenv().containsKey("BUILD_NUMBER")
buildCache
local
enabled = !inJenkins
remote(HttpBuildCache)
enabled = true
url = "$artifactory_url/gradlecache-generic-development-local/"
...
push = inJenkins
【问题讨论】:
【参考方案1】:您可能没有在 gradle 属性中启用并行性。
添加到 gradle.properties
org.gradle.parallel=true
祝你有美好的一天
【讨论】:
谢谢。知道为什么 Intellij 在 CLI 使用时不使用构建缓存属性吗?另外,我很确定我只希望构建并行而不是测试执行。 请确保在命令行和 IDE 中使用相同的 Gradle,并为“设置”设置“Gradle”(macOS 上的首选项)|构建、执行、部署 |构建工具 |摇篮 | “使用构建和运行”选项。还要在 IDE 中调用“构建”操作,而不是“重建”。以上是关于如何让 Intellij IDEA 使用并行和 gradle 构建缓存进行构建的主要内容,如果未能解决你的问题,请参考以下文章
如何让 IntelliJ IDEA 从 Maven 更新我的依赖项?
如何让 IntelliJ IDEA 在文件的每一端插入一个新行?
让 IntelliJ IDEA 为 maven 项目使用不同的 pom 文件