use of com.facebook.buck.jvm.java.JarDirectoryStep in project buck by facebook.
the class AndroidAar method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> commands = ImmutableList.builder();
// Create temp folder to store the files going to be zipped
commands.add(new MakeCleanDirectoryStep(getProjectFilesystem(), temp));
// Remove the output .aar file
commands.add(new RmStep(getProjectFilesystem(), pathToOutputFile));
// put manifest into tmp folder
commands.add(CopyStep.forFile(getProjectFilesystem(), context.getSourcePathResolver().getRelativePath(manifest.getSourcePathToOutput()), temp.resolve("AndroidManifest.xml")));
// put R.txt into tmp folder
commands.add(CopyStep.forFile(getProjectFilesystem(), context.getSourcePathResolver().getAbsolutePath(Preconditions.checkNotNull(androidResource.getPathToTextSymbolsFile())), temp.resolve("R.txt")));
// put res/ and assets/ into tmp folder
commands.add(CopyStep.forDirectory(getProjectFilesystem(), context.getSourcePathResolver().getRelativePath(assembledResourceDirectory), temp.resolve("res"), CopyStep.DirectoryMode.CONTENTS_ONLY));
commands.add(CopyStep.forDirectory(getProjectFilesystem(), context.getSourcePathResolver().getRelativePath(assembledAssetsDirectory), temp.resolve("assets"), CopyStep.DirectoryMode.CONTENTS_ONLY));
// Create our Uber-jar, and place it in the tmp folder.
commands.add(new JarDirectoryStep(getProjectFilesystem(), temp.resolve("classes.jar"), context.getSourcePathResolver().getAllAbsolutePaths(classpathsToIncludeInJar), /* mainClass */
null, /* manifestFile */
null));
// move native libs into tmp folder under jni/
if (assembledNativeLibs.isPresent()) {
commands.add(CopyStep.forDirectory(getProjectFilesystem(), assembledNativeLibs.get(), temp.resolve("jni"), CopyStep.DirectoryMode.CONTENTS_ONLY));
}
// move native assets into tmp folder under assets/lib/
for (SourcePath dir : nativeLibAssetsDirectories) {
CopyNativeLibraries.copyNativeLibrary(getProjectFilesystem(), context.getSourcePathResolver().getAbsolutePath(dir), temp.resolve("assets").resolve("lib"), ImmutableSet.of(), commands);
}
// do the zipping
commands.add(new MkdirStep(getProjectFilesystem(), pathToOutputFile.getParent()));
commands.add(new ZipStep(getProjectFilesystem(), pathToOutputFile, ImmutableSet.of(), false, ZipCompressionLevel.DEFAULT_COMPRESSION_LEVEL, temp));
buildableContext.recordArtifact(pathToOutputFile);
return commands.build();
}
use of com.facebook.buck.jvm.java.JarDirectoryStep in project buck by facebook.
the class DummyRDotJava method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, final BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
final Path rDotJavaSrcFolder = getRDotJavaSrcFolder(getBuildTarget(), getProjectFilesystem());
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), rDotJavaSrcFolder));
// Generate the .java files and record where they will be written in javaSourceFilePaths.
ImmutableSortedSet<Path> javaSourceFilePaths;
if (androidResourceDeps.isEmpty()) {
// In this case, the user is likely running a Robolectric test that does not happen to
// depend on any resources. However, if Robolectric doesn't find an R.java file, it flips
// out, so we have to create one, anyway.
// TODO(bolinfest): Stop hardcoding com.facebook. This should match the package in the
// associated TestAndroidManifest.xml file.
Path emptyRDotJava = rDotJavaSrcFolder.resolve("com/facebook/R.java");
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), emptyRDotJava.getParent()));
steps.add(new WriteFileStep(getProjectFilesystem(), "package com.facebook;\n public class R {}\n", emptyRDotJava, /* executable */
false));
javaSourceFilePaths = ImmutableSortedSet.of(emptyRDotJava);
} else {
MergeAndroidResourcesStep mergeStep = MergeAndroidResourcesStep.createStepForDummyRDotJava(getProjectFilesystem(), context.getSourcePathResolver(), androidResourceDeps, rDotJavaSrcFolder, forceFinalResourceIds, unionPackage, /* rName */
Optional.empty(), useOldStyleableFormat);
steps.add(mergeStep);
if (!finalRName.isPresent()) {
javaSourceFilePaths = mergeStep.getRDotJavaFiles();
} else {
MergeAndroidResourcesStep mergeFinalRStep = MergeAndroidResourcesStep.createStepForDummyRDotJava(getProjectFilesystem(), context.getSourcePathResolver(), androidResourceDeps, rDotJavaSrcFolder, /* forceFinalResourceIds */
true, unionPackage, finalRName, useOldStyleableFormat);
steps.add(mergeFinalRStep);
javaSourceFilePaths = ImmutableSortedSet.<Path>naturalOrder().addAll(mergeStep.getRDotJavaFiles()).addAll(mergeFinalRStep.getRDotJavaFiles()).build();
}
}
// Clear out the directory where the .class files will be generated.
final Path rDotJavaClassesFolder = getRDotJavaBinFolder();
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), rDotJavaClassesFolder));
Path pathToAbiOutputDir = getPathToAbiOutputDir(getBuildTarget(), getProjectFilesystem());
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), pathToAbiOutputDir));
Path pathToAbiOutputFile = pathToAbiOutputDir.resolve("abi.jar");
Path pathToJarOutputDir = outputJar.getParent();
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), pathToJarOutputDir));
Path pathToSrcsList = BuildTargets.getGenPath(getProjectFilesystem(), getBuildTarget(), "__%s__srcs");
steps.add(new MkdirStep(getProjectFilesystem(), pathToSrcsList.getParent()));
// Compile the .java files.
final JavacStep javacStep = RDotJava.createJavacStepForDummyRDotJavaFiles(javaSourceFilePaths, pathToSrcsList, rDotJavaClassesFolder, javacOptions, getBuildTarget(), context.getSourcePathResolver(), ruleFinder, getProjectFilesystem());
steps.add(javacStep);
buildableContext.recordArtifact(rDotJavaClassesFolder);
steps.add(new JarDirectoryStep(getProjectFilesystem(), outputJar, ImmutableSortedSet.of(rDotJavaClassesFolder), /* mainClass */
null, /* manifestFile */
null));
buildableContext.recordArtifact(outputJar);
steps.add(new CalculateAbiStep(buildableContext, getProjectFilesystem(), rDotJavaClassesFolder, pathToAbiOutputFile));
return steps.build();
}
use of com.facebook.buck.jvm.java.JarDirectoryStep in project buck by facebook.
the class GwtModule method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
Path workingDirectory = outputFile.getParent();
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), workingDirectory));
// A CopyResourcesStep is needed so that a file that is at java/com/example/resource.txt in the
// repository will be added as com/example/resource.txt in the resulting JAR (assuming that
// "/java/" is listed under src_roots in .buckconfig).
Path tempJarFolder = workingDirectory.resolve("tmp");
steps.add(new CopyResourcesStep(getProjectFilesystem(), context.getSourcePathResolver(), ruleFinder, getBuildTarget(), filesForGwtModule, tempJarFolder, context.getJavaPackageFinder()));
steps.add(new JarDirectoryStep(getProjectFilesystem(), outputFile, /* entriesToJar */
ImmutableSortedSet.of(tempJarFolder), /* mainClass */
null, /* manifestFile */
null));
buildableContext.recordArtifact(outputFile);
return steps.build();
}
use of com.facebook.buck.jvm.java.JarDirectoryStep in project buck by facebook.
the class GenAidl method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> commands = ImmutableList.builder();
commands.add(new MakeCleanDirectoryStep(getProjectFilesystem(), genPath));
BuildTarget target = getBuildTarget();
Path outputDirectory = BuildTargets.getScratchPath(getProjectFilesystem(), target, "__%s.aidl");
commands.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDirectory));
AidlStep command = new AidlStep(getProjectFilesystem(), target, context.getSourcePathResolver().getAbsolutePath(aidlFilePath), ImmutableSet.of(importPath), outputDirectory);
commands.add(command);
// Files must ultimately be written to GEN_DIR to be used as source paths.
Path genDirectory = getProjectFilesystem().getBuckPaths().getGenDir().resolve(importPath);
// Warn the user if the genDirectory is not under the output directory.
if (!importPath.startsWith(target.getBasePath().toString())) {
// TODO(shs96c): Make this fatal. Give people some time to clean up their rules.
context.getEventBus().post(ConsoleEvent.warning("%s, gen_aidl import path (%s) should be a child of %s", target, importPath, target.getBasePath()));
}
commands.add(new MkdirStep(getProjectFilesystem(), genDirectory));
commands.add(new JarDirectoryStep(getProjectFilesystem(), output, ImmutableSortedSet.of(outputDirectory), /* main class */
null, /* manifest */
null));
buildableContext.recordArtifact(output);
return commands.build();
}
Aggregations