use of com.android.tools.idea.gradle.project.sync.common.CommandLineArgs in project android by JetBrains.
the class NewGradleSync method sync.
@VisibleForTesting
@NotNull
Callback sync(@NotNull Project project) {
Callback callback = new Callback();
if (project.isDisposed()) {
callback.reject(String.format("Project '%1$s' is already disposed", project.getName()));
}
// TODO: Handle sync cancellation.
// TODO: Show Gradle output.
GradleExecutionSettings executionSettings = getOrCreateGradleExecutionSettings(project, useEmbeddedGradle());
Function<ProjectConnection, Void> syncFunction = connection -> {
List<Class<?>> modelTypes = Lists.newArrayList(AndroidProject.class, NativeAndroidProject.class, GradleBuild.class, ModuleExtendedModel.class);
BuildActionExecuter<SyncAction.ProjectModels> executor = connection.action(new SyncAction(modelTypes));
ExternalSystemTaskNotificationListener listener = new ExternalSystemTaskNotificationListenerAdapter() {
};
List<String> commandLineArgs = myCommandLineArgs.get(project);
ExternalSystemTaskId id = createId(project);
prepare(executor, id, executionSettings, listener, Collections.emptyList(), commandLineArgs, connection);
CancellationTokenSource cancellationTokenSource = newCancellationTokenSource();
executor.withCancellationToken(cancellationTokenSource.token());
try {
SyncAction.ProjectModels models = executor.run();
callback.setDone(models);
} catch (RuntimeException e) {
callback.setRejected(e);
}
return null;
};
myHelper.execute(getBaseDirPath(project).getPath(), executionSettings, syncFunction);
return callback;
}
Aggregations