Search in sources :

Example 1 with DaemonParameters

use of org.gradle.launcher.daemon.configuration.DaemonParameters in project gradle by gradle.

the class ShutdownCoordinator method stop.

public void stop() {
    ServiceRegistry clientServices = clientFactory.createStopDaemonServices(outputEventListener, new DaemonParameters(new BuildLayoutParameters()));
    DaemonStopClient client = clientServices.get(DaemonStopClient.class);
    client.gracefulStop(daemons);
}
Also used : ServiceRegistry(org.gradle.internal.service.ServiceRegistry) BuildLayoutParameters(org.gradle.initialization.BuildLayoutParameters) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) DaemonStopClient(org.gradle.launcher.daemon.client.DaemonStopClient)

Example 2 with DaemonParameters

use of org.gradle.launcher.daemon.configuration.DaemonParameters in project gradle by gradle.

the class BuildActionsFactory method createAction.

@Override
public Runnable createAction(CommandLineParser parser, ParsedCommandLine commandLine) {
    Parameters parameters = parametersConverter.convert(commandLine, null);
    parameters.getDaemonParameters().applyDefaultsFor(jvmVersionDetector.getJavaVersion(parameters.getDaemonParameters().getEffectiveJvm()));
    if (parameters.getDaemonParameters().isStop()) {
        return stopAllDaemons(parameters.getDaemonParameters());
    }
    if (parameters.getDaemonParameters().isStatus()) {
        return showDaemonStatus(parameters.getDaemonParameters());
    }
    if (parameters.getDaemonParameters().isForeground()) {
        DaemonParameters daemonParameters = parameters.getDaemonParameters();
        ForegroundDaemonConfiguration conf = new ForegroundDaemonConfiguration(UUID.randomUUID().toString(), daemonParameters.getBaseDir(), daemonParameters.getIdleTimeout(), daemonParameters.getPeriodicCheckInterval(), fileCollectionFactory);
        return new ForegroundDaemonAction(loggingServices, conf);
    }
    if (parameters.getDaemonParameters().isEnabled()) {
        return runBuildWithDaemon(parameters.getStartParameter(), parameters.getDaemonParameters());
    }
    if (canUseCurrentProcess(parameters.getDaemonParameters())) {
        return runBuildInProcess(parameters.getStartParameter(), parameters.getDaemonParameters());
    }
    return runBuildInSingleUseDaemon(parameters.getStartParameter(), parameters.getDaemonParameters());
}
Also used : ForegroundDaemonConfiguration(org.gradle.launcher.daemon.configuration.ForegroundDaemonConfiguration) ForegroundDaemonAction(org.gradle.launcher.daemon.bootstrap.ForegroundDaemonAction) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters)

Example 3 with DaemonParameters

use of org.gradle.launcher.daemon.configuration.DaemonParameters in project gradle by gradle.

the class ConnectionScopeServices method createShutdownCoordinator.

ShutdownCoordinator createShutdownCoordinator(ListenerManager listenerManager, DaemonClientFactory daemonClientFactory, OutputEventListener outputEventListener, FileCollectionFactory fileCollectionFactory) {
    ServiceRegistry clientServices = daemonClientFactory.createMessageDaemonServices(outputEventListener, new DaemonParameters(new BuildLayoutConverter().defaultValues(), fileCollectionFactory));
    DaemonStopClient client = clientServices.get(DaemonStopClient.class);
    ShutdownCoordinator shutdownCoordinator = new ShutdownCoordinator(client);
    listenerManager.addListener(shutdownCoordinator);
    return shutdownCoordinator;
}
Also used : BuildLayoutConverter(org.gradle.launcher.cli.converter.BuildLayoutConverter) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) DaemonStopClient(org.gradle.launcher.daemon.client.DaemonStopClient)

Example 4 with DaemonParameters

use of org.gradle.launcher.daemon.configuration.DaemonParameters in project gradle by gradle.

the class ProviderConnection method initParams.

private Parameters initParams(ProviderOperationParameters operationParameters) {
    CommandLineParser commandLineParser = new CommandLineParser();
    commandLineParser.allowUnknownOptions();
    commandLineParser.allowMixedSubcommandsAndOptions();
    InitialPropertiesConverter initialPropertiesConverter = new InitialPropertiesConverter();
    BuildLayoutConverter buildLayoutConverter = new BuildLayoutConverter();
    initialPropertiesConverter.configure(commandLineParser);
    buildLayoutConverter.configure(commandLineParser);
    ParsedCommandLine parsedCommandLine = commandLineParser.parse(operationParameters.getArguments() == null ? Collections.emptyList() : operationParameters.getArguments());
    InitialProperties initialProperties = initialPropertiesConverter.convert(parsedCommandLine);
    BuildLayoutResult buildLayoutResult = buildLayoutConverter.convert(initialProperties, parsedCommandLine, operationParameters.getProjectDir(), layout -> {
        if (operationParameters.getGradleUserHomeDir() != null) {
            layout.setGradleUserHomeDir(operationParameters.getGradleUserHomeDir());
        }
        layout.setProjectDir(operationParameters.getProjectDir());
    });
    AllProperties properties = new LayoutToPropertiesConverter(buildLayoutFactory).convert(initialProperties, buildLayoutResult);
    DaemonParameters daemonParams = new DaemonParameters(buildLayoutResult, fileCollectionFactory);
    new DaemonBuildOptions().propertiesConverter().convert(properties.getProperties(), daemonParams);
    if (operationParameters.getDaemonBaseDir() != null) {
        daemonParams.setBaseDir(operationParameters.getDaemonBaseDir());
    }
    // override the params with the explicit settings provided by the tooling api
    List<String> jvmArguments = operationParameters.getJvmArguments();
    if (jvmArguments != null) {
        daemonParams.setJvmArgs(jvmArguments);
    }
    // Include the system properties that are defined in the daemon JVM args
    properties = properties.merge(daemonParams.getSystemProperties());
    Map<String, String> envVariables = operationParameters.getEnvironmentVariables(null);
    if (envVariables != null) {
        daemonParams.setEnvironmentVariables(envVariables);
    }
    File javaHome = operationParameters.getJavaHome();
    if (javaHome != null) {
        daemonParams.setJvm(Jvm.forHome(javaHome));
    }
    daemonParams.applyDefaultsFor(jvmVersionDetector.getJavaVersion(daemonParams.getEffectiveJvm()));
    if (operationParameters.getDaemonMaxIdleTimeValue() != null && operationParameters.getDaemonMaxIdleTimeUnits() != null) {
        int idleTimeout = (int) operationParameters.getDaemonMaxIdleTimeUnits().toMillis(operationParameters.getDaemonMaxIdleTimeValue());
        daemonParams.setIdleTimeout(idleTimeout);
    }
    return new Parameters(daemonParams, buildLayoutResult, properties);
}
Also used : ProviderConnectionParameters(org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters) ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) AllProperties(org.gradle.launcher.configuration.AllProperties) DaemonBuildOptions(org.gradle.launcher.daemon.configuration.DaemonBuildOptions) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) InitialPropertiesConverter(org.gradle.launcher.cli.converter.InitialPropertiesConverter) BuildLayoutConverter(org.gradle.launcher.cli.converter.BuildLayoutConverter) LayoutToPropertiesConverter(org.gradle.launcher.cli.converter.LayoutToPropertiesConverter) InitialProperties(org.gradle.launcher.configuration.InitialProperties) ParsedCommandLine(org.gradle.cli.ParsedCommandLine) CommandLineParser(org.gradle.cli.CommandLineParser) File(java.io.File) BuildLayoutResult(org.gradle.launcher.configuration.BuildLayoutResult)

Example 5 with DaemonParameters

use of org.gradle.launcher.daemon.configuration.DaemonParameters in project gradle by gradle.

the class ParametersConverter method convert.

@Override
public Parameters convert(ParsedCommandLine args, Parameters target) throws CommandLineArgumentException {
    layoutConverter.convert(args, target.getLayout());
    Map<String, String> properties = new HashMap<String, String>();
    layoutToPropertiesConverter.convert(target.getLayout(), properties);
    propertiesConverter.convert(args, properties);
    propertiesToStartParameterConverter.convert(properties, (StartParameterInternal) target.getStartParameter());
    commandLineConverter.convert(args, (StartParameterInternal) target.getStartParameter());
    DaemonParameters daemonParameters = new DaemonParameters(target.getLayout(), target.getStartParameter().getSystemPropertiesArgs());
    propertiesToDaemonParametersConverter.convert(properties, daemonParameters);
    daemonConverter.convert(args, daemonParameters);
    target.setDaemonParameters(daemonParameters);
    return target;
}
Also used : HashMap(java.util.HashMap) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters)

Aggregations

DaemonParameters (org.gradle.launcher.daemon.configuration.DaemonParameters)8 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)3 DaemonStopClient (org.gradle.launcher.daemon.client.DaemonStopClient)3 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)3 BuildLayoutParameters (org.gradle.initialization.BuildLayoutParameters)2 BuildLayoutConverter (org.gradle.launcher.cli.converter.BuildLayoutConverter)2 AllProperties (org.gradle.launcher.configuration.AllProperties)2 BuildLayoutResult (org.gradle.launcher.configuration.BuildLayoutResult)2 InitialProperties (org.gradle.launcher.configuration.InitialProperties)2 DefaultBuildActionParameters (org.gradle.launcher.exec.DefaultBuildActionParameters)2 ProviderOperationParameters (org.gradle.tooling.internal.provider.connection.ProviderOperationParameters)2 File (java.io.File)1 HashMap (java.util.HashMap)1 StartParameterInternal (org.gradle.api.internal.StartParameterInternal)1 CommandLineParser (org.gradle.cli.CommandLineParser)1 ParsedCommandLine (org.gradle.cli.ParsedCommandLine)1 ClassPath (org.gradle.internal.classpath.ClassPath)1 DefaultClassPath (org.gradle.internal.classpath.DefaultClassPath)1 LoggingServiceRegistry (org.gradle.internal.logging.services.LoggingServiceRegistry)1 InitialPropertiesConverter (org.gradle.launcher.cli.converter.InitialPropertiesConverter)1