IntershopCommunicationsAG / jaxb-gradle-plugin

Gradle JAXB code generation plugin
Apache License 2.0
32 stars 15 forks source link

Incompatible with `--configuration-cache` #59

Open penn5 opened 1 year ago

penn5 commented 1 year ago

When using the gradle configuration cache, I receive the error Unable to find build service with name 'jaxbJavaGenSchema'.

Unable to find build service with name 'jaxbJavaGenSchema'.

* Try:
> 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.

* Exception is:
org.gradle.api.GradleException: Unable to find build service with name 'jaxbJavaGenSchema'.
    at com.intershop.gradle.jaxb.task.SchemaToJavaTask.getBuildService(SchemaToJavaTask.kt:387)
    at com.intershop.gradle.jaxb.task.SchemaToJavaTask.getSharedResources(SchemaToJavaTask.kt:377)
    at com.intershop.gradle.jaxb.task.SchemaToJavaTask_Decorated.getSharedResources(Unknown Source)
    at org.gradle.execution.plan.LocalTaskNode.getResourcesToLock(LocalTaskNode.java:93)
    at org.gradle.execution.plan.DefaultFinalizedExecutionPlan.tryLockSharedResourceFor(DefaultFinalizedExecutionPlan.java:388)
    at org.gradle.execution.plan.DefaultFinalizedExecutionPlan.tryAcquireLocksForNode(DefaultFinalizedExecutionPlan.java:341)
    at org.gradle.execution.plan.DefaultFinalizedExecutionPlan.attemptToStart(DefaultFinalizedExecutionPlan.java:312)
    at org.gradle.execution.plan.DefaultFinalizedExecutionPlan.selectNext(DefaultFinalizedExecutionPlan.java:279)
    at org.gradle.execution.plan.DefaultPlanExecutor$MergedQueues.selectNext(DefaultPlanExecutor.java:250)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$getNextItem$1(DefaultPlanExecutor.java:433)
    at org.gradle.internal.resources.DefaultResourceLockCoordinationService.withStateLock(DefaultResourceLockCoordinationService.java:105)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.getNextItem(DefaultPlanExecutor.java:403)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:374)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)

BUILD FAILED in 296ms
Configuration cache entry stored.

The issue occurs using the sample configurations shown in the README.

I think that Gradle is caching the phase of configuration that registers this build service, so it needs to be registered in a place that is not cached. See https://docs.gradle.org/current/userguide/configuration_cache.html.

xenoterracide commented 1 year ago

same issue, different manifestation, this is my root error

Unable to find build service with name 'jaxbJavaGenCatalogue'.
MBelniak commented 10 months ago

For me it's not even working when I have the configuration-cache directory cleared. I tried some hacky workarounds with registering the service by hand, but nothing worked :(

B-urb commented 10 months ago

I think it might have something to do with this issue: https://github.com/gradle/gradle/issues/24085

MBelniak commented 9 months ago

Why are you doing that weird function override at https://github.com/IntershopCommunicationsAG/jaxb-gradle-plugin/blob/master/src/main/kotlin/com/intershop/gradle/jaxb/task/SchemaToJavaTask.kt#L374 I forked the repo, removed that method and added this.usesService(serviceProvider) when configuring SchemaToJava task. Everything works, but I admit I have no idea why you're doing it your way in the code I mentioned.

tnielens-centrica commented 9 months ago

According to the doc, ant tasks are not fully compatible with the configuration cache https://docs.gradle.org/current/userguide/ant.html.

Ant integration is not fully compatible with the configuration cache. Using Task.ant to run Ant task in the task action may work, but importing the Ant build is not supported.