-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Remove some coupling between the client and daemon #29167
Conversation
…` to `build-state`.
…es, in the same way they can contribute global, session, etc. scoped services. Use this to move some knowledge of cross build session scoped services provided by `core` back from `build-state` to `core`.
… from `build-state` to `core`.
…daemon-services`.
…nt-side and daemon-side types.
|
||
dependencies { | ||
api(project(":core")) | ||
api(project(":base-services")) | ||
api(project(":java-language-extensions")) | ||
api(project(":core-api")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved some service registration back to core, where the services are implemented.
|
||
public class BuildProcessScopeServices { | ||
void configure(ServiceRegistration registration, ClassLoaderRegistry classLoaderRegistry) { | ||
final List<PluginServiceRegistry> pluginServiceFactories = new DefaultServiceLocator(classLoaderRegistry.getRuntimeClassLoader(), classLoaderRegistry.getPluginsClassLoader()).getAll(PluginServiceRegistry.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"build-state" is now responsible for locating all the plugin service registries, moved out of "core".
GradleUserHomeScopeServiceRegistry userHomeServiceRegistry, | ||
ServiceRegistry globalServices | ||
) { | ||
return new SetupLoggingActionExecutor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"build-state" is responsible for creating the outer most "build pipeline", which is the main entry point used by all of the things that need to run a build in the current process. Moved out of "launcher".
@@ -42,7 +42,8 @@ public BuildProcessState( | |||
ServiceRegistryBuilder builder = ServiceRegistryBuilder.builder() | |||
.scopeStrictly(Scope.Global.class) | |||
.displayName("Global services") | |||
.provider(new GlobalScopeServices(longLiving, agentStatus, additionalModuleClassPath)); | |||
.provider(new GlobalScopeServices(longLiving, agentStatus, additionalModuleClassPath)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GlobalScopeServices should be busted up, but this is a bit complicated, so in this PR leave it mostly unchanged.
@@ -110,118 +62,9 @@ void configure(ServiceRegistration registration, List<PluginServiceRegistry> plu | |||
registration.add(BuildRequestMetaData.class, buildRequestMetaData); | |||
registration.add(BuildClientMetaData.class, buildClientMetaData); | |||
registration.add(BuildEventConsumer.class, buildEventConsumer); | |||
registration.add(CalculatedValueContainerFactory.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved some service registration back to core, where the services are implemented.
this.startParameter = startParameter; | ||
} | ||
|
||
void configure(ServiceRegistration registration) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved some service registration back to core, where the services are implemented.
/** | ||
* A client-side host for {@link org.gradle.internal.invocation.BuildAction} execution. | ||
*/ | ||
public class ClientBuildRequestContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new client-side context type, split out of BuildRequestContext. It mostly mirrors the daemon-side context, but can later gain some additional state, such as the InputStream
to consume "stdin" from.
import org.gradle.internal.UncheckedException; | ||
|
||
import java.io.IOException; | ||
|
||
public class GradleLauncherMetaData implements BuildClientMetaData { | ||
public class GradleLauncherMetaData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to "daemon-protocol" and detangled from the "build process" type.
private final long startTime; | ||
private final boolean interactive; | ||
private final BuildActionParameters parameters; | ||
|
||
public Build(UUID identifier, byte[] token, BuildAction action, BuildClientMetaData buildClientMetaData, long startTime, boolean interactive, BuildActionParameters parameters) { | ||
public Build(UUID identifier, byte[] token, BuildAction action, GradleLauncherMetaData buildClientMetaData, long startTime, boolean interactive, BuildActionParameters parameters) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the shared type to carry client metadata from client to daemon.
import org.gradle.tooling.internal.provider.serialization.PayloadSerializer; | ||
import org.gradle.tooling.internal.provider.serialization.WellKnownClassLoaderRegistry; | ||
|
||
public class DaemonServices extends AbstractPluginServiceRegistry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New service registry for the services implemented in "daemon-services", moved out of "launcher".
System.in, | ||
globalServices.get(BuildExecutor.class) | ||
); | ||
BuildActionExecutor<BuildActionParameters, ClientBuildRequestContext> executor = new RunInProcess( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the client-side context instead of the daemon-side context in the gradle
client, but when running in-process, use some adapters to convert client-side to daemon-side.
@@ -32,18 +30,18 @@ | |||
import org.gradle.tooling.internal.provider.action.ExecuteBuildAction; | |||
|
|||
public class RunBuildAction implements Runnable { | |||
private final BuildActionExecutor<BuildActionParameters, BuildRequestContext> executer; | |||
private final BuildActionExecutor<BuildActionParameters, ClientBuildRequestContext> executor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use client-side context in the gradle
client.
@@ -53,7 +56,9 @@ protected void doBuild(final DaemonCommandExecution execution, Build build) { | |||
DaemonConnectionBackedEventConsumer buildEventConsumer = new DaemonConnectionBackedEventConsumer(execution); | |||
try { | |||
BuildCancellationToken cancellationToken = execution.getDaemonStateControl().getCancellationToken(); | |||
BuildRequestContext buildRequestContext = new DefaultBuildRequestContext(build.getBuildRequestMetaData(), cancellationToken, buildEventConsumer); | |||
DefaultBuildClientMetaData clientMetaData = new DefaultBuildClientMetaData(build.getBuildClientMetaData()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adapt from shared protocol type to daemon-side context in the daemon.
registration.addProvider(new ToolingGlobalScopeServices()); | ||
} | ||
|
||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved some service registration to "daemon-services" and "build-state".
@@ -27,20 +27,20 @@ | |||
import org.gradle.launcher.exec.DefaultBuildActionParameters; | |||
import org.gradle.tooling.internal.provider.connection.ProviderOperationParameters; | |||
|
|||
public class DaemonBuildActionExecuter implements BuildActionExecutor<ConnectionOperationParameters, BuildRequestContext> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the client-side context in the tooling API client.
@@ -34,17 +34,17 @@ | |||
/** | |||
* A {@link BuildActionExecutor} which routes Gradle logging to those listeners specified in the {@link ProviderOperationParameters} provided with a tooling api build request. | |||
*/ | |||
public class LoggingBridgingBuildActionExecuter implements BuildActionExecutor<ConnectionOperationParameters, BuildRequestContext> { | |||
public class LoggingBridgingBuildActionExecuter implements BuildActionExecutor<ConnectionOperationParameters, ClientBuildRequestContext> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the client-side context in the tooling API client.
@@ -258,10 +258,10 @@ private Object run( | |||
Parameters parameters | |||
) { | |||
try { | |||
BuildActionExecutor<ConnectionOperationParameters, BuildRequestContext> executer = createExecuter(providerParameters, parameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the client-side context in the tooling API client.
import java.io.Closeable; | ||
import java.io.File; | ||
|
||
public class CoreBuildSessionServices { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved some service registrations back to "core".
import org.gradle.internal.work.DefaultWorkerLeaseService; | ||
import org.gradle.internal.work.WorkerLeaseService; | ||
|
||
public class CoreCrossBuildSessionServices { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved some service registrations back to "core".
Context
This PR removes some usages of "build process" (eg the daemon) types from the client implementation.
BuildRequestContext
to instead use separate client-side and daemon-side context. This allows the types to carry different information represented using different types.It also applies some clean-up of the "daemon-protocol", "daemon-services", "client-services" and "build-state" projects:
Contributor Checklist
<subproject>/src/integTest
) to verify changes from a user perspective.<subproject>/src/test
) to verify logic../gradlew sanityCheck
../gradlew <changed-subproject>:quickTest
.Reviewing cheatsheet
Before merging the PR, comments starting with