Search in sources :

Example 1 with InstantRunBuilder

use of com.android.tools.idea.fd.InstantRunBuilder 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)

Aggregations

InstantRunBuilder (com.android.tools.idea.fd.InstantRunBuilder)1 InstantRunContext (com.android.tools.idea.fd.InstantRunContext)1 GradleBuildInvoker (com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker)1 BuildMode (com.android.tools.idea.gradle.util.BuildMode)1