use of com.android.tools.idea.fd.InstantRunContext in project android by JetBrains.
the class MakeBeforeRunTaskProvider method createBuilder.
private static BeforeRunBuilder createBuilder(@NotNull ExecutionEnvironment env, @NotNull Module[] modules, @NotNull RunConfiguration configuration, @Nullable AndroidRunConfigContext runConfigContext, @Nullable String userGoal) {
if (modules.length == 0) {
throw new IllegalStateException("Unable to determine list of modules to build");
}
if (!isEmpty(userGoal)) {
return new DefaultGradleBuilder(Collections.singletonList(userGoal), null);
}
GradleModuleTasksProvider gradleTasksProvider = new GradleModuleTasksProvider(modules);
GradleBuildInvoker.TestCompileType testCompileType = GradleBuildInvoker.getTestCompileType(configuration.getType().getId());
if (testCompileType == GradleBuildInvoker.TestCompileType.UNIT_TESTS) {
BuildMode buildMode = BuildMode.COMPILE_JAVA;
return new DefaultGradleBuilder(gradleTasksProvider.getUnitTestTasks(buildMode), buildMode);
}
InstantRunContext irContext = env.getCopyableUserData(InstantRunContext.KEY);
DeviceFutures deviceFutures = runConfigContext == null ? null : runConfigContext.getTargetDevices();
if (deviceFutures == null || irContext == null) {
return new DefaultGradleBuilder(gradleTasksProvider.getTasksFor(BuildMode.ASSEMBLE, testCompileType), BuildMode.ASSEMBLE);
}
List<AndroidDevice> targetDevices = deviceFutures.getDevices();
assert targetDevices.size() == 1 : "instant run context available, but deploying to > 1 device";
return new InstantRunBuilder(getLaunchedDevice(targetDevices.get(0)), irContext, runConfigContext, gradleTasksProvider);
}
use of com.android.tools.idea.fd.InstantRunContext in project android by JetBrains.
the class RestartActivityAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Module module = LangDataKeys.MODULE.getData(e.getDataContext());
if (module == null) {
return;
}
InstantRunContext context = InstantRunGradleUtils.createGradleProjectContext(module);
if (context == null) {
Logger.getInstance(RestartActivityAction.class).info("Unable to obtain instant run context for module: " + module.getName());
return;
}
restartActivity(module.getProject(), context);
}
Aggregations