Search in sources :

Example 1 with StartParameterConverter

use of org.gradle.launcher.cli.converter.StartParameterConverter in project gradle by gradle.

the class ProviderStartParameterConverter method toStartParameter.

public StartParameterInternal toStartParameter(ProviderOperationParameters parameters, BuildLayoutResult buildLayout, AllProperties properties) {
    // Important that this is constructed on the client so that it has the right gradleHomeDir and other state internally
    StartParameterInternal startParameter = new StartParameterInternal();
    List<InternalLaunchable> launchables = parameters.getLaunchables();
    if (launchables != null) {
        startParameter.setTaskRequests(unpack(launchables));
    } else if (parameters.getTasks() != null) {
        startParameter.setTaskNames(parameters.getTasks());
    }
    List<String> arguments = parameters.getArguments();
    StartParameterConverter converter = new StartParameterConverter();
    CommandLineParser parser = new CommandLineParser();
    new InitialPropertiesConverter().configure(parser);
    new BuildLayoutConverter().configure(parser);
    converter.configure(parser);
    ParsedCommandLine parsedCommandLine;
    try {
        parsedCommandLine = parser.parse(arguments != null ? arguments : Collections.emptyList());
    } 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', '-p'." + "\nExamples of unsupported build options: '--daemon', '-?', '-v'." + "\nPlease find more information in the javadoc for the BuildLauncher class.", e);
    }
    converter.convert(parsedCommandLine, buildLayout, properties, startParameter);
    if (parameters.getBuildLogLevel() != null) {
        startParameter.setLogLevel(parameters.getBuildLogLevel());
    }
    return startParameter;
}
Also used : StartParameterConverter(org.gradle.launcher.cli.converter.StartParameterConverter) InitialPropertiesConverter(org.gradle.launcher.cli.converter.InitialPropertiesConverter) BuildLayoutConverter(org.gradle.launcher.cli.converter.BuildLayoutConverter) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) ParsedCommandLine(org.gradle.cli.ParsedCommandLine) CommandLineParser(org.gradle.cli.CommandLineParser) 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 CommandLineParser (org.gradle.cli.CommandLineParser)1 ParsedCommandLine (org.gradle.cli.ParsedCommandLine)1 BuildLayoutConverter (org.gradle.launcher.cli.converter.BuildLayoutConverter)1 InitialPropertiesConverter (org.gradle.launcher.cli.converter.InitialPropertiesConverter)1 StartParameterConverter (org.gradle.launcher.cli.converter.StartParameterConverter)1 InternalLaunchable (org.gradle.tooling.internal.protocol.InternalLaunchable)1 InternalUnsupportedBuildArgumentException (org.gradle.tooling.internal.protocol.exceptions.InternalUnsupportedBuildArgumentException)1