Is it possible to register a NativeServices service, specifically a process launcher, using a plugin? This is to modify the behavior of exec

My goal is to use NuProcessBuilder instead of ProcessBuilder to start processes on Windows, so that long-running or background-style child processes, like starting a node server, are automatically terminated when the Gradle daemon is terminated. Currently they are not.

When and how would I apply such a plugin?

package com.example

import net.rubygrapefruit.platform.ProcessLauncher

class ProcessPlugin implements Plugin<Project> {
  void apply(Project target) {
    NativeServices.getInstance().register(serviceRegistration -> {
      serviceRegistration.add(ProcessLauncher.class, new NuProcessLauncher())

This doesn’t work, because NativeServices is no longer mutable - the file system is requested too early on. When is the earliest I can add such a service?

I would upstream this fix.

I see that the injection of the process launcher service happens here:

    protected ProcessLauncher createProcessLauncher() {
        if (useNativeIntegrations) {
            try {
                return net.rubygrapefruit.platform.Native.get(ProcessLauncher.class);
            } catch (NativeIntegrationUnavailableException e) {
                LOGGER.debug("Native-platform process launcher is not available. Continuing with fallback.");
        return new DefaultProcessLauncher();

So it’s not clear to me if registering a service would address the issue. Does anyone have experience with this?