use of io.flutter.run.SdkRunConfig in project flutter-intellij by flutter.
the class RunFlutterAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
// NOTE: When making changes here, consider making similar changes to ConnectAndroidDebuggerAction.
FlutterInitializer.sendAnalyticsAction(this);
final RunnerAndConfigurationSettings settings = getRunConfigSettings(e);
if (settings == null) {
return;
}
final RunConfiguration configuration = settings.getConfiguration();
if (!(configuration instanceof SdkRunConfig)) {
// Action is disabled; shouldn't happen.
return;
}
final SdkRunConfig sdkRunConfig = (SdkRunConfig) configuration.clone();
final SdkFields fields = sdkRunConfig.getFields();
final String additionalArgs = fields.getAdditionalArgs();
String flavorArg = null;
if (fields.getBuildFlavor() != null) {
flavorArg = "--flavor=" + fields.getBuildFlavor();
}
final List<String> args = new ArrayList<>();
if (additionalArgs != null) {
args.add(additionalArgs);
}
if (flavorArg != null) {
args.add(flavorArg);
}
if (!args.isEmpty()) {
fields.setAdditionalArgs(Joiner.on(" ").join(args));
}
final Executor executor = getExecutor(myExecutorId);
if (executor == null) {
return;
}
final ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.create(executor, sdkRunConfig);
final ExecutionEnvironment env;
try {
env = builder.activeTarget().dataContext(e.getDataContext()).build();
} catch (IllegalStateException ex) {
// the reason why. This adds a bit more diagnostics to the exception to help us determine what's going on.
throw new IllegalStateException(ex.getMessage() + " (" + myExecutorId + "/" + myLaunchMode + "/" + getClass().getSimpleName() + ")");
}
FlutterLaunchMode.addToEnvironment(env, myLaunchMode);
ProgramRunnerUtil.executeConfiguration(env, false, true);
}
Aggregations