@Override @NonNull public synchronized ImmutableList<ApkOutputFile> getOutputSplitFiles() { final String archivesBaseName = (String)getProject().getProperties().get("archivesBaseName"); final ImmutableList.Builder<ApkOutputFile> outputFiles = ImmutableList.builder(); InputProcessor addingLogic = new InputProcessor() { @Override public void process(String split, File file) { outputFiles.add(new ApkOutputFile( OutputType.SPLIT, ImmutableList.of( FilterDataImpl.build( getFilterType(split).toString(), getFilter(split))), Callables.returning( new File( outputDirectory, archivesBaseName + "-" + outputBaseName + "_" + split + ".apk")))); } }; forEachUnalignedInput(addingLogic); forEachUnsignedInput(addingLogic); return outputFiles.build(); }
@TaskAction public void splitZipAlign() throws IOException { final String archivesBaseName = (String)getProject().getProperties().get("archivesBaseName"); InputProcessor zipAlignIt = new InputProcessor() { @Override public void process(final String split, final File file) { final File out = new File(getOutputDirectory(), archivesBaseName + "-" + outputBaseName + "_" + split + ".apk"); getProject().exec(new Action<ExecSpec>() { @Override public void execute(ExecSpec execSpec) { execSpec.setExecutable(getZipAlignExe()); execSpec.args("-f", "4"); execSpec.args(file.getAbsolutePath()); execSpec.args(out); } }); } }; forEachUnalignedInput(zipAlignIt); forEachUnsignedInput(zipAlignIt); saveApkMetadataFile(); }