Пример #1
0
 @Override
 public ConfiguredAspect create(
     ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) {
   String information =
       parameters.isEmpty()
           ? ""
           : " data " + Iterables.getFirst(parameters.getAttribute("baz"), null);
   return new ConfiguredAspect.Builder(getClass().getName(), ruleContext)
       .addProvider(
           AspectInfo.class,
           new AspectInfo(
               collectAspectData("aspect " + ruleContext.getLabel() + information, ruleContext)))
       .build();
 }
Пример #2
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();
 }
Пример #3
0
 @Override
 public ConfiguredAspect create(
     ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) {
   StringBuilder information = new StringBuilder("aspect " + ruleContext.getLabel());
   if (!parameters.isEmpty()) {
     information.append(" data " + Iterables.getFirst(parameters.getAttribute("baz"), null));
     information.append(" ");
   }
   List<? extends TransitiveInfoCollection> deps =
       ruleContext.getPrerequisites("$dep", Mode.TARGET);
   information.append("$dep:[");
   for (TransitiveInfoCollection dep : deps) {
     information.append(" ");
     information.append(dep.getLabel());
   }
   information.append("]");
   return new ConfiguredAspect.Builder(getClass().getName(), ruleContext)
       .addProvider(
           AspectInfo.class,
           new AspectInfo(collectAspectData(information.toString(), ruleContext)))
       .build();
 }