https://gradle.com/ logo
Join Slack
Powered by
# configuration-cache
  • k

    kyle

    10/04/2024, 9:12 PM
    Hi folks. Is there a CC-compatible substitute for the o.g.a.Project#project(String) method? My use-case is that I have a project reference as a String, like
    :subprojectFoo
    and I need to find its projectDir. I know that I should probably be providing this value as a task input but... it's complicated.
    t
    v
    • 3
    • 22
  • j

    Javi

    10/07/2024, 4:23 PM
    I have a
    ValueSource
    and its params interface. This interface is taking a
    Property<VersionMapper>
    , and this mapper extends
    Serializable
    .
    Copy code
    interface Params : ValueSourceParameters {
            val versionMapper: Property<VersionMapper>
            ...
    }
    
    public fun interface VersionMapper : Serializable {
    
        public fun map(version: GradleVersion): String
    }
    But I am getting the next crash with config cache enabled:
    Copy code
    > Could not create task ':playground-kotlin-version:printSemver'.
       > Could not isolate value com.javiersc.semver.project.gradle.plugin.valuesources.VersionValueSource$Params_Decorated@3cad81e8 of type VersionValueSource.Params
          > Could not serialize value of type Build_gradle..
    I know the issue is around this
    VersionMapper
    because if I remove it from params, it works.
    v
    • 2
    • 5
  • j

    Javi

    10/07/2024, 6:19 PM
    Related to the above, I am getting this error:
    Copy code
    > Could not create task ':printSemver'.
       > Could not isolate value com.javiersc.semver.project.gradle.plugin.valuesources.VersionValueSource$Params_Decorated@6c6a363a of type VersionValueSource.Params
          > Could not serialize value of type $Proxy80
    The problem is when the script is written in Groovy instead of in Kotlin.
    Copy code
    semver {
       mapVersion { "1.0.0" }
    }
    Should I use something like
    Transformer
    instead my own
    VersionMapper
    interface? I think I would have the same issue with
    Transformer
    as that API does not extend serializable.
    πŸ‘€ 1
    v
    • 2
    • 23
  • a

    Arve Seljebu

    10/07/2024, 6:29 PM
    Hi πŸ‘‹ What files should I look into for caching of environmental variables? I think I’ve found a bug. It’s put in backlog. To me, it sounds like a good first issue, but I have not found / understood where gradle caches environment variables. I have found platforms/core-configuration/configuration-cache/ and a bunch of files mentioning environment, like org/gradle/internal/cc/impl/services/Environment.kt. I’ve read some of them, but not all. Naively,
    Environtment
    does seem to cache all environment variables:
    Copy code
    TrackingProperties(System.getenv()) // πŸ‘ˆ no input of which environmental variables the task depend on
    But I’m unsure how to verify this. Where should I put a test like this?
    Copy code
    fun `should bypass environmental variables that are not task dependencies when using configuration-cache`
    And are there any similar tests that I can use as a template?
    m
    • 2
    • 2
  • k

    kyle

    10/17/2024, 12:27 AM
    Hi folks. I've created a
    Provider<String>
    on a helper object which performs a semi-expensive shell-out the the terminal to fetch the version of a tool. I don't know why I thought this, but I expected the body of the method to be cached. Instead it is invoked each time I access the method. What am I doing wrong? Ideally the callable would be invoked once and the result cached each time I access
    getExpensiveVersionOfLocalThing().get()
    .
    Copy code
    public Provider<String> getExpensiveVersionOfLocalThing() {
        return getProviderFactory().provider(() -> {
          // do expensive thing
          return expensiveResult;
        });
      }
    e
    j
    • 3
    • 10
  • m

    Martin

    11/03/2024, 12:47 PM
    Is there any advantage to using
    providers.environmentVariable("FOO")
    vs directly
    provider { System.getenv("FOO") }
    given that CC is invalidated on value changes in both cases?
    v
    m
    • 3
    • 13
  • m

    Martin

    11/04/2024, 5:19 PM
    Is
    Provider.map {}
    allowed with the configuration cache? I'm hitting a weird use case where it doesn't carry task dependencies:
    Copy code
    val task1 = tasks.register("mytask1", MyTask::class) {
      myInput.set("input1")
      myOutputFile.set(layout.buildDirectory.file("output1.txt"))
    }
    
    val task2 = tasks.register("mytask2", MyTask::class) {
      myInput.set(task1.map { it.myOutputFile.get().asFile.readText() + "Suffix"})
      myOutputFile.set(layout.buildDirectory.file("output2.txt"))
    }
    output:
    Copy code
    build/output1.txt (No such file or directory)
    Is that a bug or am I using it wrong?
    v
    m
    • 3
    • 16
  • c

    Clayton Walker

    11/13/2024, 11:08 PM
    Is it possible to know if a dependent task has ran? A configuration-cacheable alternative to Task::getDidWork for cases where it’d be nice to know if, during the build, another task did work.
    v
    • 2
    • 1
  • r

    Ramiro Aparicio Gallardo

    11/15/2024, 2:04 PM
    I am trying to create a task that enforces the usage of catalog dependencies if possible, so it checks if dependencies that could be used from the catalog were included using coordinates instead. I was able to do that by checking the classes of the dependencies to distinguish if a dependency comes from the catalog or not ( I needed to check an internal type but afaik that is the only way possible), but I am struggling to make that task compatible with the configuration-cache. I need something like this at task execution time:
    Copy code
    project.configurations.getByName("testRuntimeClasspath").allDependencies
    Configuration and DependencySet can not be cached but they will also not be properly populated at task configuration time. ResolvedComponentResult or ResolvedArtifactResult can be used via providers but those are dependencies already resolved and afaik they will not know if it comes from a catalog or not. Is there any way to make it work with the cache?
    v
    • 2
    • 3
  • n

    Nikolay

    11/19/2024, 9:18 AM
    Hello, I have a question about isolated projects. I have just attempted to try it out on our multi-project gradle build. We have a nested structure with project names derived from the leaf folders. To avoid name clashes we have
    build.gradle.kts
    files in parent folders that look like this
    Copy code
    allprojects {
        group = "unique-group-name"
    }
    This appears to break project isolation. Is there a recommended way of fixing this for project isolation?
    a
    v
    t
    • 4
    • 13
  • k

    Kevin Brightwell

    12/20/2024, 7:11 PM
    πŸ‘‹ Is there a way to generate the report/peek at the content used for a configuration-cache entry? We’re trying to re-use configuration-cache entries in our ephemeral CI builds but a simple β€œtar up
    .gradle/configuration-cache
    and then un-tar it in the repeated run” has the configuration-cache not re-used with no other information presented in the scan
    j
    j
    +3
    • 6
    • 129
  • j

    Jason Pearson

    12/28/2024, 7:11 PM
    I don't want to hijack the above thread - @Nicklas Ansman does
    --dry-run
    give you an overall smaller transforms size while still providing config cache reuse?
  • n

    Nicklas Ansman

    12/28/2024, 8:11 PM
    Much much smaller.
    πŸ‘€ 2
    🧡 1
  • n

    Nicklas Ansman

    12/28/2024, 8:12 PM
    It will produce transforms needed to configure the build as opposed to transforms needed to build your entire project
    🧡 1
    πŸ™„ 1
  • v

    Vidyasagar Samudrala

    12/30/2024, 5:41 AM
    Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options. PS C:\Users\Lenovo\flutterProjects> flutter run Launching lib\main.dart on sdk gphone x86 in debug mode... FAILURE: Build failed with an exception. * What went wrong: Could not open settings generic class cache for settings file 'C:\Users\Lenovo\flutterProjects\android\settings.gradle' (C:\Users\Lenovo\.gradle\caches\7.5\scripts\3d075fs9hjp81ny0sgym4v09w).
    BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65
    * Try:
    Run with --stacktrace option to get the stack trace.
    Run with --info or --debug option to get more log output.
    Run with --scan to get full insights.
    * Get more help at https://help.gradle.org BUILD FAILED in 1s Running Gradle task 'assembleDebug'... 1,989ms β”Œβ”€ Flutter Fix ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ β”‚ [!] Your project's Gradle version is incompatible with the Java version that Flutter is using for Gradle. β”‚ β”‚ β”‚ β”‚ If you recently upgraded Android Studio, consult the migration guide at docs.flutter.dev/go/android-java-gradle-error. β”‚ β”‚ β”‚ β”‚ Otherwise, to fix this issue, first, check the Java version used by Flutter by running
    flutter doctor --verbose
    . β”‚ β”‚ β”‚ β”‚ Then, update the Gradle version specified in C:\Users\Lenovo\flutterProjects\android\gradle\wrapper\gradle-wrapper.properties to be compatible with that Java version. See the link below for more information on compatible β”‚ β”‚ Java/Gradle versions: β”‚ β”‚ https://docs.gradle.org/current/userguide/compatibility.html#java β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ Error: Gradle task assembleDebug failed with exit code 1 getting this issue
    v
    • 2
    • 1
  • r

    Rohitha Sivani Jarubula

    01/13/2025, 10:02 AM
    hello
    πŸ‘‹ 2
  • g

    Gaurav Guleria

    01/20/2025, 7:46 AM
    Hi, can someone help me in understanding this: https://github.com/google/protobuf-gradle-plugin/pull/719/files If I am not wrong, aren't these two things effectively the same? Create a
    Provider
    , so that
    inputFiles.files
    is accessed lazily during execution, when the task action queries the fileCollection and the sources added need to be resolved.
    Copy code
    return objectFactory.fileCollection()
            .from(providerFactory.provider { unused ->
              Set<File> files = inputFiles.files
              // use files
    Use
    FileCollection.getElements()
    which is also just provides
    Provider
    for accessing inputFile.files
    Copy code
    return objectFactory.fileCollection()
            .from(inputFiles.getElements().map { files ->
              // use files
    How does the former code access
    inputFiles.files
    eagerly?
    v
    m
    • 3
    • 12
  • w

    Wojciech ZiΔ™ba

    01/29/2025, 4:21 PM
    hi πŸ‘‹ Do you disable Configuration Cache (CC) on CI? In all of our projects where we’ve enabled it, we’ve noticed that configuration time *increases*β€”on average by a minute, sometimes even more. I came across a discussion in Kotlin’s Gradle channel, and I understand that CC is supposed to help with task parallelization. However, in our case (across three apps), we’re not seeing any improvementsβ€”instead, we see that Gradle spends time on β€œCalculating task graph as no cached configuration is available for tasks.” which is not later reused. I’m curious - does this suggest an issue with our configuration, or do most of you simply disable CC on CI?
    πŸ‘€ 2
    v
    j
    +4
    • 7
    • 36
  • m

    Mudasar Cheema

    02/05/2025, 2:04 PM
    Hi! When i have enabled
    Copy code
    org.gradle.unsafe.configuration-cache=true
    in my
    gradle.properties
    i have problem building my project because of this error:
    Copy code
    * What went wrong:
    Unable to find build service with name 'jaxbJavaGenTss'.
    Why am I facing this issue and how to resolve it? Pasting my
    build.gradle.kts
    file in thread
    v
    • 2
    • 2
  • a

    Andrew Grosner

    02/06/2025, 11:05 PM
    im getting an interesting bug where configuration cache misses:
    Copy code
    Configuration on demand is an incubating feature.
    Calculating task graph as configuration cache cannot be reused because an input to task ':buildSrc:compileJava' has changed.
    but ive only changed code within a library module code, nothing in buildSrc. anyway to debug / diagnose?
    πŸ‘€ 1
    v
    • 2
    • 3
  • c

    Clayton Walker

    02/11/2025, 11:15 PM
    Is there a configuration-cache/task-avoidance -acceptable way of excluding classes from jacoco reports? What I see copy-pasted mostly comes from https://stackoverflow.com/questions/29887805/filter-jacoco-coverage-reports-with-gradle, namely
    Copy code
    jacocoTestReport {
        afterEvaluate {
            classDirectories.setFrom(files(classDirectories.files.collect {
                fileTree(dir: it, exclude: 'com/blah/**')
            }))
        }
    }
    but I'm wondering if there are better ways now?
    v
    • 2
    • 5
  • n

    Nicola Corti

    02/13/2025, 5:10 PM
    Hey all, What is the correct way to make this task CC friendly?
    Copy code
    val myCmakeTask by tasks.registering(Exec::class) {
        commandLine("cmake", "--build", "build")
        standardOutput = FileOutputStream("$buildDir/cmake-output.log")
        errorOutput = FileOutputStream("$buildDir/cmake-error.log")
    }
    seems like
    standardOutput
    and
    errorOutput
    are causing the problem here. Specifically:
    Copy code
    cannot serialize object of type `java.io.FileOutputStream`, a subtype of `java.io.OutputStream`, as these are not supported with the configuration cache. Only `System.out` or `System.err` can be used there.
    I can’t use
    System.out
    or
    System.err
    as I want to write on file.
    m
    • 2
    • 2
  • s

    StefMa

    02/17/2025, 3:36 PM
    Hey guys, I'm curious about the configuration cache behaviour. These are the steps happen: 1. Configuration phase 2. Storing in CC 3. Loading from CC This happen when there is no CC or something changed. I just ask myself if its necessary to load the cache, after it has been stored... Its actually "not a big deal", but for me it just feels strange that it loads again. Everything should be already there/in memory, otherwise it couldn't have been saved, right? 😁 So out of curiosity, is this "needed" to behave like that? Or could this be improved?
    m
    • 2
    • 3
  • n

    NADiNE

    03/29/2025, 9:16 AM
    Your project is configured with Android NDK 26.3.11579264, but the following plugin(s) depend on a different Android NDK version: - installed_apps requires Android NDK 27.0.12077973 Fix this issue by using the highest Android NDK version (they are backward compatible). Add the following to /Users/nadinjoma/StudioProjects/parental_control_app/android/app/build.gradle.kts: android { ndkVersion = "27.0.12077973" ... } lib/main.dart469: Error: No named parameter with the name 'excludeSystemApps'. excludeSystemApps: true, ^^^^^^^^^^^^^^^^^ ../../.pub-cache/hosted/pub.dev/installed_apps-1.6.0/lib/installed_apps.dart1632: Context: Found this candidate, but the arguments don't match. static Future<List<AppInfo>> getInstalledApps([ ^^^^^^^^^^^^^^^^ Target kernel_snapshot_program failed: Exception FAILURE: Build failed with an exception. * What went wrong: Execution failed for task 'appcompileFlutterBuildDebug'.
    Process 'command '/Users/nadinjoma/development/flutter/bin/flutter'' finished with non-zero exit value 1
    * Try:
    Run with --stacktrace option to get the stack trace.
    Run with --info or --debug option to get more log output.
    Run with --scan to get full insights.
    Get more help at https://help.gradle.org.
    BUILD FAILED in 1m 30s Running Gradle task 'assembleDebug'... 91.5s Error: Gradle task assembleDebug failed with exit code 1. any help??
    v
    • 2
    • 1
  • k

    kyle

    04/09/2025, 8:56 PM
    Hi folks. My environment has dozens of JUnit 3 suite classes - we typically invoke one suite per CI runner - and these are invoked in a proprietary way i.e. not using Gradle. Now I'm registering dozens of
    Test
    tasks (one per suite) but am finding the need to have a custom "label" for each task . For example, labeling them one of [red, green, blue]. I was considering using
    ext
    to set a custom property, i.e.
    task.ext.color = 'blue'
    , or I could register a custom extension type. Are either of these approaches going to break configuration caching? Will querying the extension at build-time cause the task to be eagerly created? In pseudocode, I might have a CI trigger which runs something like:
    Copy code
    tasks.withType(Test).collect {
      it.hasExtension(MyCustomColorExtension) and
      it.color == 'blue'
    }...
    This would enumerate the subset of tasks I need to pass to another downstream system.
    v
    r
    • 3
    • 7
  • g

    Giuseppe Barbieri

    04/23/2025, 2:11 PM
    I'm trying to enable the configuration cache on one of our project, but I get the following error within the Kotlin Compile task Is there anything I may try?
    v
    t
    • 3
    • 3
  • i

    Isaac Kirabo

    04/30/2025, 11:17 AM
    i am trying to run my flutter program and i have java 17 it shows this error can anyone help please
  • i

    Isaac Kirabo

    04/30/2025, 11:18 AM
    Launching lib\main.dart on Android SDK built for x86 in debug mode... Support for Android x86 targets will be removed in the next stable release after 3.27. See https://github.com/flutter/flutter/issues/157543 for details. FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'android'.
    Could not resolve all files for configuration ':classpath'.
    > Could not find com.android.tools.buildG 8.0.0. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/ 8.0.0/gradle- 8.0.0.pom - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/ 8.0.0/gradle- 8.0.0.pom Required by: project : * Try:
    Run with --stacktrace option to get the stack trace.
    Run with --info or --debug option to get more log output.
    Run with --scan to get full insights.
    * Get more help at https://help.gradle.org BUILD FAILED in 6m 41s Error: Gradle task assembleDebug failed with exit code 1 Exited (1).
    🧡 1
    v
    • 2
    • 2
  • m

    Michael

    05/03/2025, 8:38 AM
    Hi all I'm trying to enable configuration cache for my project. I'm running
    Copy code
    ./gradlew assemble --configuration-cache
    First run
    Copy code
    Calculating task graph as no cached configuration is available for tasks: assemble
    [Build log]
    Configuration cache entry stored.
    Second run
    Copy code
    Calculating task graph as configuration cache cannot be reused because the file system entry 'build/classes/java/main' has been created.
    [Build log]
    Configuration cache entry stored.
    Third run
    Copy code
    Reusing configuration cache.
    [Build log]
    Configuration cache entry reused.
    How can I debug what depends on
    build/classes/java/main
    ? I'm using
    Copy code
    plugins {
        id 'java'
        id "org.springframework.boot" version "3.4.5"
        id "io.spring.dependency-management" version "1.1.7"
        id "org.openapi.generator" version "7.13.0"
        id "org.sonarqube" version "6.1.0.5360"
        id 'jacoco'
        id "io.freefair.lombok" version "8.13.1"
    }
    and gradle 8.14.
    m
    v
    • 3
    • 7
  • c

    Clayton Walker

    05/07/2025, 11:56 PM
    Is there a configuration-cache compatible way of doing the following: Taking a list of configuration (ConfigurationContainer, NamedDomainObjectCollection) and turn them into an input to a task? For example calling
    Copy code
    .map { it.incoming.resolutionResult.root }
    causes us to realize/create each configuration? So even if the output of this is cc-compatible, it still causes us to realized the collection. Is this fine if it's done in a configureEach, as it'll only be realized if the task is actually called? It just seems like unlike Property/Provider, there's no map/flatMap for the named object collections.
    • 1
    • 1