/** * Creates a {@link MiddlemanType#AGGREGATING_MIDDLEMAN aggregating} middleman. * * @param owner the owner of the action that will be created; must not be null * @param purpose the purpose for which this middleman is created. This should be a string which * is suitable for use as a filename. A single rule may have many middlemen with distinct * purposes. * @param inputs the set of artifacts for which the created artifact is to be the middleman. * @param middlemanDir the directory in which to place the middleman. * @return null iff {@code inputs} is empty; the single element of {@code inputs} if there's only * one; a new aggregating middleman for the {@code inputs} otherwise */ public Artifact createAggregatingMiddleman( ActionOwner owner, String purpose, Iterable<Artifact> inputs, Root middlemanDir) { if (hasExactlyOneInput(inputs)) { // Optimization: No middleman for just one input. return Iterables.getOnlyElement(inputs); } Pair<Artifact, Action> result = createMiddleman( owner, Label.print(owner.getLabel()), purpose, inputs, middlemanDir, MiddlemanType.AGGREGATING_MIDDLEMAN); return result == null ? null : result.getFirst(); }