graphql-java-generator / graphql-gradle-plugin-project

graphql-gradle-plugin is a Gradle Plugin for GraphQL, based on graphql-java. It accelerates the development for both the client and the server, by generating the Java code. It allows a quicker development when in contract-first approach, by avoiding to code the boilerplate code.
https://graphql-maven-plugin-project.graphql-java-generator.com/
MIT License
54 stars 8 forks source link

GeneratePojoTask incompatible with Gradle 8 configuration cache #14

Closed steven-sheehy closed 7 months ago

steven-sheehy commented 1 year ago

Trying to upgrade my project to Gradle 8 and use the new configuration cache. I'm currently using gradle.plugin.com.graphql-java-generator:graphql-gradle-plugin:1.18.10. When enabling the experimental configuration cache I get the following error:

$ ./gradlew :graphql:generatePojo --configuration-cache --stacktrace
Configuration cache is an incubating feature.
Configuration on demand is an incubating feature.
Calculating task graph as no configuration cache is available for tasks: :graphql:generatePojo
The Gradle Enterprise plugin has been disabled as it is incompatible with this version of Gradle and the configuration caching feature - please upgrade to version 3.12 or later of the Gradle Enterprise plugin to restore functionality.

FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Task `:graphql:generatePojo` of type `com.graphql_java_generator.gradleplugin.GeneratePojoTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
  See https://docs.gradle.org/8.0.2/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

See the complete report at file:///Users/foo/bar/build/reports/configuration-cache/76q33ac5ydnkm43tuo3a645kk/e3g98w8zyw8u1zik2latswgzt/configuration-cache-report.html

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.configurationcache.ConfigurationCacheProblemsException: Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Task `:graphql:generatePojo` of type `com.graphql_java_generator.gradleplugin.GeneratePojoTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
  See https://docs.gradle.org/8.0.2/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

See the complete report at file:///Users/foo/bar/build/reports/configuration-cache/76q33ac5ydnkm43tuo3a645kk/e3g98w8zyw8u1zik2latswgzt/configuration-cache-report.html
        at org.gradle.configurationcache.problems.ConfigurationCacheProblems.report(ConfigurationCacheProblems.kt:161)
        at org.gradle.internal.buildtree.ProblemReportingBuildActionRunner.reportProblems(ProblemReportingBuildActionRunner.java:61)
        at org.gradle.internal.buildtree.ProblemReportingBuildActionRunner.run(ProblemReportingBuildActionRunner.java:52)
        at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:65)
        at org.gradle.tooling.internal.provider.FileSystemWatchingBuildActionRunner.run(FileSystemWatchingBuildActionRunner.java:140)
        at org.gradle.launcher.exec.BuildCompletionNotifyingBuildActionRunner.run(BuildCompletionNotifyingBuildActionRunner.java:41)
        at org.gradle.launcher.exec.RootBuildLifecycleBuildActionExecutor.lambda$execute$0(RootBuildLifecycleBuildActionExecutor.java:40)
        at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:122)
        at org.gradle.launcher.exec.RootBuildLifecycleBuildActionExecutor.execute(RootBuildLifecycleBuildActionExecutor.java:40)
        at org.gradle.internal.buildtree.DefaultBuildTreeContext.execute(DefaultBuildTreeContext.java:40)
        at org.gradle.launcher.exec.BuildTreeLifecycleBuildActionExecutor.lambda$execute$0(BuildTreeLifecycleBuildActionExecutor.java:65)
        at org.gradle.internal.buildtree.BuildTreeState.run(BuildTreeState.java:53)
        at org.gradle.launcher.exec.BuildTreeLifecycleBuildActionExecutor.execute(BuildTreeLifecycleBuildActionExecutor.java:65)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor$3.call(RunAsBuildOperationBuildActionExecutor.java:61)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor$3.call(RunAsBuildOperationBuildActionExecutor.java:57)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor.execute(RunAsBuildOperationBuildActionExecutor.java:57)
        at org.gradle.launcher.exec.RunAsWorkerThreadBuildActionExecutor.lambda$execute$0(RunAsWorkerThreadBuildActionExecutor.java:36)
        at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:249)
        at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:109)
        at org.gradle.launcher.exec.RunAsWorkerThreadBuildActionExecutor.execute(RunAsWorkerThreadBuildActionExecutor.java:36)
        at org.gradle.tooling.internal.provider.continuous.ContinuousBuildActionExecutor.execute(ContinuousBuildActionExecutor.java:110)
        at org.gradle.tooling.internal.provider.SubscribableBuildActionExecutor.execute(SubscribableBuildActionExecutor.java:64)
        at org.gradle.internal.session.DefaultBuildSessionContext.execute(DefaultBuildSessionContext.java:46)
        at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter$ActionImpl.apply(BuildSessionLifecycleBuildActionExecuter.java:100)
        at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter$ActionImpl.apply(BuildSessionLifecycleBuildActionExecuter.java:88)
        at org.gradle.internal.session.BuildSessionState.run(BuildSessionState.java:69)
        at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter.execute(BuildSessionLifecycleBuildActionExecuter.java:62)
        at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter.execute(BuildSessionLifecycleBuildActionExecuter.java:41)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:63)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:31)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:50)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:38)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:47)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:31)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:65)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:29)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75)
        at org.gradle.util.internal.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:64)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:84)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:49)

* Get more help at https://help.gradle.org

BUILD FAILED in 718ms
11 actionable tasks: 11 up-to-date
Configuration cache entry discarded with 1 problem.
etienne-sf commented 1 year ago

Hello,

You're right, the plugin execution is not compatible with the gradle --configuration-cache parameter.

I'll check that Etienne

steven-sheehy commented 8 months ago

Hi @etienne-sf any chance you were able to look into this? It seems like the main change would be to move the 3 paths targetResourceFolder, targetSourceFolder, and schemaPersonalizationFile in GenerateCodeCommonExtension to be modeled as task inputs instead as Gradle recommends.

I attempted to clone the repo to attempt to contribute but I can't even get the project to compile. Are there any contribution guides? It seems like it requires an older 1.8 java version, but even when using that JDK it fails with:

graphql-gradle-plugin-project$ ./gradlew build

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'graphql-gradle-plugin-project'.
> Could not determine the dependencies of null.
   > Could not resolve all task dependencies for configuration ':classpath'.
      > Could not resolve org.springframework:spring-context:6.0.9.
        Required by:
            project : > project :graphql-gradle-plugin3
         > No matching variant of org.springframework:spring-context:6.0.9 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6.1' but:
             - Variant 'apiElements' capability org.springframework:spring-context:6.0.9 declares a library, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 8
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
             - Variant 'runtimeElements' capability org.springframework:spring-context:6.0.9 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 8
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
      > Could not resolve org.springframework:spring-context:5.3.31.
        Required by:
            project : > project :graphql-gradle-plugin > com.graphql-java-generator:graphql-maven-plugin-logic:2.4 > com.graphql-java-generator:graphql-java-common-runtime:2.4 > com.graphql-java-generator:graphql-java-common-dependencies:2.4
         > No matching variant of org.springframework:spring-context:6.0.9 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6.1' but:
             - Variant 'apiElements' capability org.springframework:spring-context:6.0.9 declares a library, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 8
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
             - Variant 'runtimeElements' capability org.springframework:spring-context:6.0.9 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 8
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')

Might consider bumping the java version to one that's not end of life.

etienne-sf commented 8 months ago

Hello,

You're right, I must update the Gradle version. To be honest, I postponed this one, as I'm tired of fighting against Gradle: making the Gradle plugin work is way more complex than with the Maven one.

And I'll check the Howto compile, also. Thanks for the report.

Étienne

etienne-sf commented 8 months ago

I updated the howto build page : the needed java version is 17. It actually generates two plugins:

Making the build compatible with the Gradle configuration cache was far from easy. It was actually quite a journey.

But it's now done, and will be available in the next release.

etienne-sf commented 7 months ago

Solved in the 2.5 release

steven-sheehy commented 7 months ago

Thanks a lot @etienne-sf! I'll test out the new release soon.