Jmix entity enhancer tasks fail with Gradle Configuration Cache

Hello,

We are testing Gradle Configuration Cache in a multi-build repository with Jmix Gradle plugin 3.0.2 and Gradle wrapper 9.5.1.

The cache fails in the Jmix entity enhancer tasks (enhanceJmixMain and enhanceJmixTest) in 4 application builds. The other seven builds (jmix addons) pass. The full pipeline passes with --no-configuration-cache.

The Configuration Cache report identifies Task.project access at execution time (use_project_during_execution) in the enhancer task. We also tried Jmix Gradle plugin 3.0.3; the failure still occurred at enhanceJmixMain.

Is there any recommended fix that makes these enhancer tasks Configuration Cache compatible? I can provide the full Gradle report or a reproducer if useful.

@tom.monnier We noticed something appearing similar - I’m not sure if it is. https://forum.jmix.io/t/sometimes-entitymanager-has-problem-compiling-any-query-for-any-entity/4218/3

See also: https://github.com/jmix-framework/jmix/issues/3102

Please provide a reproducible test case, it will help a lot.

Regards,
Konstantin

Hi Konstantin,

I reduced this to a standalone project and verified it with Gradle 9.5.1 and Microsoft OpenJDK 21.0.7 on Windows. Both Jmix Gradle plugin 3.0.2 and 3.0.3 reproduce the failure.

The complete project sources are below. It needs only two empty Java classes; no entities, application dependencies, database, custom tasks, or init scripts are required.

settings.gradle:

rootProject.name = 'jmix-configuration-cache-reproducer'

build.gradle:

plugins {
    id 'io.jmix' version '3.0.2'
    id 'java'
}

jmix {
    bomVersion = '3.0.2'
    projectId = 'repro'
}

repositories {
    mavenCentral()
    maven { url = 'https://global.repo.jmix.io/repository/public' }
}

src/main/java/example/Example.java:

package example;

public class Example {
}

src/test/java/example/ExampleTest.java (plain Java class, no test framework needed):

package example;

public class ExampleTest {
}

Use a Gradle 9.5.1 wrapper (distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip). If needed, generate it with gradle wrapper --gradle-version 9.5.1 --distribution-type bin.

From the project directory, run these commands separately:

# Main enhancer: fails
.\gradlew.bat clean enhanceJmixMain --configuration-cache --no-build-cache --no-daemon --console=plain

# Test enhancer in isolation: fails
.\gradlew.bat clean enhanceJmixTest -x enhanceJmixMain --configuration-cache --no-build-cache --no-daemon --console=plain

# Control: both enhancers succeed
.\gradlew.bat clean enhanceJmixMain enhanceJmixTest --no-configuration-cache --no-build-cache --no-daemon --console=plain

On Linux/macOS, use ./gradlew instead. The -x enhanceJmixMain in the second command lets the test enhancer run without stopping first at the main enhancer failure.

For the main enhancer, the output is:

> Task :enhanceJmixMain FAILED

1 problem was found storing the configuration cache.
- Task `:enhanceJmixMain` of type `org.gradle.api.DefaultTask`: invocation of 'Task.project' at execution time is unsupported with the configuration cache.

Execution failed for task ':enhanceJmixMain' (registered by plugin 'io.jmix').
> Invocation of 'Task.project' by task ':enhanceJmixMain' at execution time is unsupported with the configuration cache.

Configuration cache entry discarded with 1 problem.

The isolated test command reports the same error for :enhanceJmixTest.

I repeated all three commands after changing both the plugin version and bomVersion to 3.0.3:

Jmix version Main with configuration cache Test with configuration cache Both without configuration cache
3.0.2 Fails: Task.project Fails: Task.project Passes
3.0.3 Fails: Task.project Fails: Task.project Passes

This isolates the build-time failure from the original multi-build repository. Does this give you enough to investigate configuration-cache support in the enhancer tasks?

Thanks,
Tom

Hi Tom,
Thank you for the detailed scenario.
We’ll check it, create an issue and let you know when we’ll be able to fix it.

Regards,
Konstantin

Hi Tom,

Thank you for reporting the problem.

We reproduced the problem on Jmix 3.0.2 (and 3.1.999) with Gradle 9.5.1. Both enhanceJmixMain and enhanceJmixTest fail when the configuration cache is enabled, and both work without it. The cause is in the Jmix Gradle plugin: the enhancing action reads Task.project while the task is executing, which the configuration cache does not allow.

We have created an issue for it: jmix-framework/jmix#5913

Regards,
Igor