【问题标题】:How to make Intellij IDEA use parallel and gradle build cache for building如何让 Intellij IDEA 使用并行和 gradle 构建缓存进行构建
【发布时间】: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
  }
}

【问题讨论】:

    标签: gradle intellij-idea gradle-cache


    【解决方案1】:

    您可能没有在 gradle 属性中启用并行性。

    添加到 gradle.properties

    org.gradle.parallel=true
    

    祝你有美好的一天

    【讨论】:

    • 谢谢。知道为什么 Intellij 在 CLI 使用时不使用构建缓存属性吗?另外,我很确定我只希望构建并行而不是测试执行。
    • 请确保在命令行和 IDE 中使用相同的 Gradle,并为“设置”设置“Gradle”(macOS 上的首选项)|构建、执行、部署 |构建工具 |摇篮 | “使用构建和运行”选项。还要在 IDE 中调用“构建”操作,而不是“重建”。
    猜你喜欢
    • 2015-02-20
    • 1970-01-01
    • 2018-01-11
    • 1970-01-01
    • 2020-02-23
    • 2016-09-03
    • 1970-01-01
    • 2014-02-07
    • 1970-01-01
    相关资源
    最近更新 更多