Exemple #1
0
 @Override
 public AspectDefinition getDefinition(AspectParameters aspectParameters) {
   AspectDefinition.Builder builder =
       new AspectDefinition.Builder("parametrized_definition_aspect")
           .attributeAspect("foo", ParametrizedDefinitionAspect.class);
   ImmutableCollection<String> baz = aspectParameters.getAttribute("baz");
   if (baz != null) {
     try {
       builder.add(attr("$dep", LABEL).value(Label.parseAbsolute(baz.iterator().next())));
     } catch (LabelSyntaxException e) {
       throw new IllegalStateException();
     }
   }
   return builder.build();
 }
  @Override
  public AspectDefinition getDefinition(AspectParameters aspectParameters) {
    AspectDefinition.Builder builder =
        new AspectDefinition.Builder(NAME)
            .attributeAspect("runtime_deps", AndroidStudioInfoAspect.class)
            .attributeAspect("resources", AndroidStudioInfoAspect.class)
            .add(
                attr("$packageParser", LABEL)
                    .cfg(HOST)
                    .exec()
                    .value(
                        Label.parseAbsoluteUnchecked(
                            Constants.TOOLS_REPOSITORY + "//tools/android:PackageParser")));

    for (PrerequisiteAttr prerequisiteAttr : PREREQUISITE_ATTRS) {
      builder.attributeAspect(prerequisiteAttr.name, AndroidStudioInfoAspect.class);
    }

    return builder.build();
  }