Beispiel #1
0
  @Override
  public List<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext)
      throws IOException {
    ImmutableList.Builder<Step> commands = ImmutableList.builder();

    // Clear out the old file, if it exists.
    commands.add(
        new RmStep(pathToOutputFile, /* shouldForceDeletion */ true, /* shouldRecurse */ false));

    // Make sure the directory for the output file exists.
    commands.add(new MkdirStep(pathToOutputFile.getParent()));

    commands.add(
        new GenerateManifestStep(
            skeletonFile.resolve(context).toString(), manifestFiles, getPathToOutputFile()));

    return commands.build();
  }
    @Override
    public ImmutableList<Step> getBuildSteps(
        BuildContext context, BuildableContext buildableContext) {
      ImmutableList.Builder<Step> steps = ImmutableList.builder();
      steps.add(new MakeCleanDirectoryStep(unpackDirectory));
      steps.add(new UnzipStep(aarFile.resolve(), unpackDirectory));
      steps.add(new TouchStep(getProguardConfig()));
      steps.add(new MkdirStep(getAssetsDirectory()));

      // For now, we do not support an .aar file that has entries in the libs directory.
      // Basically, this is for simplicity because we do not know how many more prebuilt_jar rules
      // we would have to add at enhacement time. If this is a problem in practice, then we can
      // add a step that generates an uber-jar from classes.jar and the contents of the libs
      // directory and then have the prebuilt_jar step wrap the uber-jar instead of classes.jar.
      // Because there are not many .aar files in the wild, it is difficult to tell whether this
      // will be a pain point for developers.
      steps.add(
          new AbstractExecutionStep("check_for_libs") {
            @Override
            public int execute(ExecutionContext context) {
              Path libsDirectory = unpackDirectory.resolve("libs");
              ProjectFilesystem projectFilesystem = context.getProjectFilesystem();
              if (!projectFilesystem.exists(libsDirectory)) {
                return 0;
              }

              if (projectFilesystem.listFiles(libsDirectory).length > 0) {
                context.logError(
                    new IllegalArgumentException(),
                    "Error processing %s for %s. "
                        + "Currently, Buck does not support .aar files with lib entries. "
                        + "If this is a problem for you, please file an issue on GitHub.",
                    aarFile,
                    getBuildTarget());
                return 1;
              } else {
                return 0;
              }
            }
          });

      buildableContext.recordArtifactsInDirectory(unpackDirectory);
      return steps.build();
    }
Beispiel #3
0
 @Override
 public RuleKey.Builder appendDetailsToRuleKey(RuleKey.Builder builder) {
   return builder.set("skeleton", skeletonFile.asReference()).set("manifestFiles", manifestFiles);
 }