use of com.facebook.buck.zip.ZipStep in project buck by facebook.
the class JavaSourceJar method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
JavaPackageFinder packageFinder = context.getJavaPackageFinder();
ImmutableList.Builder<Step> steps = ImmutableList.builder();
steps.add(new MkdirStep(getProjectFilesystem(), output.getParent()));
steps.add(new RmStep(getProjectFilesystem(), output));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), temp));
Set<Path> seenPackages = Sets.newHashSet();
for (Path source : context.getSourcePathResolver().filterInputsToCompareToOutput(sources)) {
Path packageFolder = packageFinder.findJavaPackageFolder(source);
Path packageDir = temp.resolve(packageFolder);
if (seenPackages.add(packageDir)) {
steps.add(new MkdirStep(getProjectFilesystem(), packageDir));
}
steps.add(CopyStep.forFile(getProjectFilesystem(), source, packageDir.resolve(source.getFileName())));
}
steps.add(new ZipStep(getProjectFilesystem(), output, ImmutableSet.of(), /* junk paths */
false, DEFAULT_COMPRESSION_LEVEL, temp));
buildableContext.recordArtifact(output);
return steps.build();
}
use of com.facebook.buck.zip.ZipStep in project buck by facebook.
the class IntraDexReorderStep method reorderEntry.
private int reorderEntry(Path inputPath, boolean isPrimaryDex, ImmutableList.Builder<Step> steps) {
if (!isPrimaryDex) {
String tmpname = "dex-tmp-" + inputPath.getFileName().toString() + "-%s";
Path temp = BuildTargets.getScratchPath(filesystem, buildTarget, tmpname);
// Create tmp directory if necessary
steps.add(new MakeCleanDirectoryStep(filesystem, temp));
// un-zip
steps.add(new UnzipStep(filesystem, inputPath, temp));
// run reorder tool
steps.add(new DefaultShellStep(filesystem.getRootPath(), ImmutableList.of(reorderTool.toString(), reorderDataFile.toString(), temp.resolve("classes.dex").toString())));
Path outputPath = Paths.get(inputPath.toString().replace(inputSubDir, outputSubDir));
// re-zip
steps.add(new ZipStep(filesystem, outputPath, /* paths */
ImmutableSet.of(), /* junkPaths */
false, ZipCompressionLevel.MAX_COMPRESSION_LEVEL, temp));
} else {
// copy dex
// apply reorder directly on dex
steps.add(CopyStep.forFile(filesystem, inputPrimaryDexPath, outputPrimaryDexPath));
steps.add(new DefaultShellStep(filesystem.getRootPath(), ImmutableList.of(reorderTool.toString(), reorderDataFile.toString(), outputPrimaryDexPath.toString())));
}
return 0;
}
Aggregations