Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Gradle 7.4 configuration caching #211

Merged
merged 4 commits into from
Feb 5, 2022

Conversation

nhoughto
Copy link
Contributor

  • Removed the props variable in PlatformHelper to avoid failures in 7.4
  • Refactored use of PlatformHelper.INSTANCE just to tasks, the task then passes down its helper instance for Runner / VariantComputer use
  • Added a new BaseTask class to hold common properties across all tasks, since PlatformHelper.INSTANCE isn't used anymore
  • Tweaked some tests to use the Task sourced PlatformHelper, making execution deterministic and avoiding race conditions, no need for racey originalPlatformHelper anymore. Can probably run more tests in parallel now?
  • Tweaked the proxy test server stuff to pass, non-secure would throw 404 for me, can likely back this out with more context. Also tweaked the request verification to be less fragile, was failing for me.

@@ -47,10 +46,7 @@ class YarnProxy_integTest extends AbstractIntegTest {
request.removeHeader("host")
def targetHost = "registry.npmjs.org"
request.withHeader("host", targetHost)
if (secure) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't really sure what the deal with this was? npm registry is always doing to be secure upstream, you get a redirect if you connect over port 80.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Java supports both a HTTP and a HTTPS proxy we used to test that both worked, with HTTP support dropped I gave a brief try fixing the tests but got unpredictable results and instead disabled the HTTP tests (there's a separate issue for the proxy tests)

.withPath("/case")
.withHeader("Host", "registry.npmjs.org:${port}"),
exactly(1))
proxyMockServer.verify(request()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this assertion was important or not? can't see why it would be, failed on my local either way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's #195 for the broken tests, when we test the proxy support we install the case module and then have this assert verify that the request actually went through the proxy (which in our case is the mockserver proxying the request)

// Added so that we can test osArch on Windows and on non-arm systems
if (name == "uname") execute("uname", "-m")
else error("Unable to find a value for property [$name].")
}

open fun getSystemProperty(name: String): String? {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be a more kotlin-y way to do this 🤷‍♂️

@deepy
Copy link
Member

deepy commented Feb 1, 2022

I just need to look through the test changes, but so far it looks great 👍

I was pleasantly surprised to see that Gradle 7.4 supports Automatic detection of environment variables, system properties and Gradle properties used at configuration time

Especially

[..] and external values can be read using standard Java and Gradle APIs. Environment variables, system properties and Gradle properties used at configuration time are automatically detected without requiring build or plugin authors to migrate to Gradle specific APIs.

(sorry, cat walked over keyboard)

@deepy deepy added this to the 3.2 milestone Feb 1, 2022
@deepy
Copy link
Member

deepy commented Feb 2, 2022

Looks good 👍

I've copied this branch into the repository and switched to 7.4-rc2 that released today, going to have a look tomorrow to see if the next release will be a major or minor and do some manual testing to make sure the proxy support still works

If all looks good I'll merge this to master, move the remainders in the current milestone to the top of the next milestone and push a release

@nhoughto
Copy link
Contributor Author

nhoughto commented Feb 2, 2022 via email

@deepy
Copy link
Member

deepy commented Feb 3, 2022

Yup, got all that's needed, I'll publish the release tonight

@nhoughto
Copy link
Contributor Author

nhoughto commented Feb 4, 2022

ok great, then i can stop maintaining my private fork 👍

@deepy deepy merged commit bbd601e into node-gradle:master Feb 5, 2022
@morj
Copy link

morj commented Feb 10, 2022

Hi! I'm getting the following error with a bulid restored from the configuration cache with gradle-node-plugin version 3.2.0.

Failed to stop service 'gradle-node-modules'.

lateinit property fileHasher has not been initialized

  • Try:

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

* Exception is:
org.gradle.api.services.internal.ServiceLifecycleException: Failed to stop service 'gradle-node-modules'.
        at org.gradle.api.services.internal.BuildServiceProvider.lambda$maybeStop$1(BuildServiceProvider.java:177)
        at org.gradle.internal.Try$Success.ifSuccessful(Try.java:179)
        at org.gradle.api.services.internal.BuildServiceProvider.maybeStop(BuildServiceProvider.java:172)
        at org.gradle.api.services.internal.DefaultBuildServicesRegistry$ServiceCleanupListener.buildFinished(DefaultBuildServicesRegistry.java:260)
        at jdk.internal.reflect.GeneratedMethodAccessor538.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:464)
        at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:446)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:61)
        at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:434)
        at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:421)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:43)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:245)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:157)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:61)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:346)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:249)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:141)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
        at com.sun.proxy.$Proxy28.buildFinished(Unknown Source)
        at org.gradle.internal.build.DefaultBuildLifecycleController.lambda$finishBuild$8(DefaultBuildLifecycleController.java:195)
        at org.gradle.internal.model.StateTransitionController.lambda$finish$11(StateTransitionController.java:218)
        at org.gradle.internal.work.DefaultSynchronizer.withLock(DefaultSynchronizer.java:44)
        at org.gradle.internal.model.StateTransitionController.finish(StateTransitionController.java:209)
        at org.gradle.internal.build.DefaultBuildLifecycleController.finishBuild(DefaultBuildLifecycleController.java:183)
        at org.gradle.internal.buildtree.DefaultBuildTreeFinishExecutor.finishBuildTree(DefaultBuildTreeFinishExecutor.java:55)
        at org.gradle.configurationcache.ConfigurationCacheAwareFinishExecutor.finishBuildTree(ConfigurationCacheAwareFinishExecutor.kt:28)
        at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.lambda$runBuild$4(DefaultBuildTreeLifecycleController.java:111)
        at org.gradle.internal.model.StateTransitionController.lambda$transition$6(StateTransitionController.java:166)
        at org.gradle.internal.model.StateTransitionController.doTransition(StateTransitionController.java:238)
        at org.gradle.internal.model.StateTransitionController.lambda$transition$7(StateTransitionController.java:166)
        at org.gradle.internal.work.DefaultSynchronizer.withLock(DefaultSynchronizer.java:44)
        at org.gradle.internal.model.StateTransitionController.transition(StateTransitionController.java:166)
        at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.runBuild(DefaultBuildTreeLifecycleController.java:103)
        at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.scheduleAndRunTasks(DefaultBuildTreeLifecycleController.java:69)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:31)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.internal.buildtree.ProblemReportingBuildActionRunner.run(ProblemReportingBuildActionRunner.java:49)
        at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:69)
        at org.gradle.tooling.internal.provider.FileSystemWatchingBuildActionRunner.run(FileSystemWatchingBuildActionRunner.java:119)
        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:128)
        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:270)
        at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:119)
        at org.gradle.launcher.exec.RunAsWorkerThreadBuildActionExecutor.execute(RunAsWorkerThreadBuildActionExecutor.java:36)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecutor.execute(ContinuousBuildActionExecutor.java:103)
        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:58)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
        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:55)
        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:48)
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property fileHasher has not been initialized
        at org.jetbrains.kotlin.gradle.targets.js.npm.AbstractNodeModulesCache.getFileHasher(AbstractNodeModulesCache.kt:31)
        at org.jetbrains.kotlin.gradle.targets.js.npm.AbstractNodeModulesCache$cache$2.invoke(AbstractNodeModulesCache.kt:35)
        at org.jetbrains.kotlin.gradle.targets.js.npm.AbstractNodeModulesCache$cache$2.invoke(AbstractNodeModulesCache.kt:33)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at org.jetbrains.kotlin.gradle.targets.js.npm.AbstractNodeModulesCache.getCache(AbstractNodeModulesCache.kt:33)
        at org.jetbrains.kotlin.gradle.targets.js.npm.AbstractNodeModulesCache.close(AbstractNodeModulesCache.kt:62)
        at org.gradle.api.services.internal.BuildServiceProvider.lambda$maybeStop$1(BuildServiceProvider.java:175)
        ... 105 more

Do we need a separate MR for this?

@deepy
Copy link
Member

deepy commented Feb 10, 2022

It'd be great if you could create a separate issue for it with a small project that shows it being triggered

I'm still recovering from a fever so there'll be some days before I can have a proper look at things again

@nhoughto
Copy link
Contributor Author

This isn't related to this gradle plugin i don't think, the error in question is related to a build service 'gradle-node-modules' which this plugin doesn't create or register (i dont think?), seems to be from the kotlin-gradle-plugin

Here: https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants