Search in sources :

Example 6 with CommandLineArgumentException

use of org.gradle.cli.CommandLineArgumentException 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

CommandLineArgumentException (org.gradle.cli.CommandLineArgumentException)6 RunManagerEx (com.intellij.execution.RunManagerEx)2 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 ExternalTaskExecutionInfo (com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo)2 NotificationData (com.intellij.openapi.externalSystem.service.notification.NotificationData)2 Project (com.intellij.openapi.project.Project)2 Map (java.util.Map)2 CommandLineParser (org.gradle.cli.CommandLineParser)2 ParsedCommandLine (org.gradle.cli.ParsedCommandLine)2 NotNull (org.jetbrains.annotations.NotNull)2 ExecuteGradleTaskHistoryService (org.jetbrains.plugins.gradle.service.task.ExecuteGradleTaskHistoryService)2 GradleRunTaskDialog (org.jetbrains.plugins.gradle.service.task.GradleRunTaskDialog)2 BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 ExternalSystemAction (com.intellij.openapi.externalSystem.action.ExternalSystemAction)1 ExternalSystemActionUtil (com.intellij.openapi.externalSystem.action.ExternalSystemActionUtil)1