Search in sources :

Example 1 with InstantRunContext

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);
}
Also used : InstantRunContext(com.android.tools.idea.fd.InstantRunContext) InstantRunBuilder(com.android.tools.idea.fd.InstantRunBuilder) BuildMode(com.android.tools.idea.gradle.util.BuildMode) GradleBuildInvoker(com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker)

Example 2 with InstantRunContext

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);
}
Also used : InstantRunContext(com.android.tools.idea.fd.InstantRunContext) Module(com.intellij.openapi.module.Module)

Aggregations

InstantRunContext (com.android.tools.idea.fd.InstantRunContext)2 InstantRunBuilder (com.android.tools.idea.fd.InstantRunBuilder)1 GradleBuildInvoker (com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker)1 BuildMode (com.android.tools.idea.gradle.util.BuildMode)1 Module (com.intellij.openapi.module.Module)1