Search in sources :

Example 1 with DefaultCommandLineConverter

use of org.gradle.initialization.DefaultCommandLineConverter in project gradle by gradle.

the class ProviderStartParameterConverter method toStartParameter.

public StartParameterInternal toStartParameter(ProviderOperationParameters parameters, Map<String, String> properties) {
    // Important that this is constructed on the client so that it has the right gradleHomeDir and other state internally
    StartParameterInternal startParameter = new StartParameterInternal();
    startParameter.setProjectDir(parameters.getProjectDir());
    if (parameters.getGradleUserHomeDir() != null) {
        startParameter.setGradleUserHomeDir(parameters.getGradleUserHomeDir());
    }
    List<InternalLaunchable> launchables = parameters.getLaunchables(null);
    if (launchables != null) {
        startParameter.setTaskRequests(unpack(launchables, parameters.getProjectDir()));
    } else if (parameters.getTasks() != null) {
        startParameter.setTaskNames(parameters.getTasks());
    }
    new PropertiesToStartParameterConverter().convert(properties, startParameter);
    List<String> arguments = parameters.getArguments();
    if (arguments != null) {
        DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
        try {
            converter.convert(arguments, startParameter);
        } catch (CommandLineArgumentException e) {
            throw new InternalUnsupportedBuildArgumentException("Problem with provided build arguments: " + arguments + ". " + "\n" + e.getMessage() + "\nEither it is not a valid build option or it is not supported in the target Gradle version." + "\nNot all of the Gradle command line options are supported build arguments." + "\nExamples of supported build arguments: '--info', '-u', '-p'." + "\nExamples of unsupported build options: '--daemon', '-?', '-v'." + "\nPlease find more information in the javadoc for the BuildLauncher class.", e);
        }
    }
    if (parameters.isSearchUpwards() != null) {
        startParameter.setSearchUpwards(parameters.isSearchUpwards());
    }
    if (parameters.getBuildLogLevel() != null) {
        startParameter.setLogLevel(parameters.getBuildLogLevel());
    }
    if (parameters.getStandardInput() != null) {
        startParameter.setInteractive(true);
    }
    return startParameter;
}
Also used : DefaultCommandLineConverter(org.gradle.initialization.DefaultCommandLineConverter) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) PropertiesToStartParameterConverter(org.gradle.launcher.cli.converter.PropertiesToStartParameterConverter) InternalUnsupportedBuildArgumentException(org.gradle.tooling.internal.protocol.exceptions.InternalUnsupportedBuildArgumentException) CommandLineArgumentException(org.gradle.cli.CommandLineArgumentException) InternalLaunchable(org.gradle.tooling.internal.protocol.InternalLaunchable)

Aggregations

StartParameterInternal (org.gradle.api.internal.StartParameterInternal)1 CommandLineArgumentException (org.gradle.cli.CommandLineArgumentException)1 DefaultCommandLineConverter (org.gradle.initialization.DefaultCommandLineConverter)1 PropertiesToStartParameterConverter (org.gradle.launcher.cli.converter.PropertiesToStartParameterConverter)1 InternalLaunchable (org.gradle.tooling.internal.protocol.InternalLaunchable)1 InternalUnsupportedBuildArgumentException (org.gradle.tooling.internal.protocol.exceptions.InternalUnsupportedBuildArgumentException)1