class InstantRunSplitApkBuilder extends Transform {

    @NonNull
    protected File generateSplitApk(@NonNull ApkData apkData, @NonNull DexFiles dexFiles)
            throws IOException, KeytoolException, PackagerException, ProcessException,
                    TransformException {

        String uniqueName = dexFiles.encodeName();
        final File alignedOutput = new File(outputDirectory, uniqueName + ".apk");
        Files.createParentDirs(alignedOutput);

        try (CloseableBlockingResourceLinker aapt = getLinker()) {
            File resPackageFile =
                    generateSplitApkResourcesAp(
                            logger,
                            aapt,
                            applicationIdSupplier,
                            apkData,
                            supportDirectory,
                            aaptOptions,
                            androidBuilder,
                            uniqueName,
                            resources);

            // packageCodeSplitApk uses a temporary directory for incremental runs. Since we don't
            // do incremental builds here, make sure it gets an empty directory.
            File tempDir = new File(supportDirectory, "package_" + uniqueName);
            if (!tempDir.exists() && !tempDir.mkdirs()) {
                throw new TransformException(
                        "Cannot create temporary folder " + tempDir.getAbsolutePath());
            }

            FileUtils.cleanOutputDir(tempDir);

            androidBuilder.packageCodeSplitApk(
                    resPackageFile,
                    dexFiles.dexFiles,
                    SigningConfigMetadata.Companion.load(signingConf),
                    alignedOutput,
                    tempDir,
                    ApkCreatorFactories.fromProjectProperties(project, true));

            buildContext.addChangedFile(FileType.SPLIT, alignedOutput);
            deleteIfExists(resPackageFile.toPath());
        }

        return alignedOutput;
    }

    public  InstantRunSplitApkBuilder(
            @NonNull Logger logger,
            @NonNull Project project,
            @NonNull InstantRunBuildContext buildContext,
            @NonNull AndroidBuilder androidBuilder,
            @Nullable FileCollection aapt2FromMaven,
            @NonNull Supplier<String> applicationIdSupplier,
            @Nullable FileCollection signingConf,
            @NonNull AaptOptions aaptOptions,
            @NonNull File outputDirectory,
            @NonNull File supportDirectory,
            @NonNull BuildableArtifact resources,
            @NonNull BuildableArtifact resourcesWithMainManifest,
            @NonNull BuildableArtifact apkList,
            @NonNull ApkData mainApk);

}