private Artifact getStampFileArtifact(String middlemanName, String purpose, Root middlemanDir) { String escapedFilename = Actions.escapedPath(middlemanName); PathFragment stampName = new PathFragment("_middlemen/" + escapedFilename + "-" + purpose); Artifact stampFile = artifactFactory.getDerivedArtifact(stampName, middlemanDir, actionRegistry.getOwner()); return stampFile; }
/** * Creates both normal and scheduling middlemen. * * <p>Note: there's no need to synchronize this method; the only use of a field is via a call to * another synchronized method (getArtifact()). * * @return null iff {@code inputs} is null or empty; the middleman file and the middleman action * otherwise */ private Pair<Artifact, Action> createMiddleman( ActionOwner owner, String middlemanName, String purpose, Iterable<Artifact> inputs, Root middlemanDir, MiddlemanType middlemanType) { if (inputs == null || Iterables.isEmpty(inputs)) { return null; } Artifact stampFile = getStampFileArtifact(middlemanName, purpose, middlemanDir); Action action = new MiddlemanAction(owner, inputs, stampFile, purpose, middlemanType); actionRegistry.registerAction(action); return Pair.of(stampFile, action); }
/** * Creates a normal middleman. * * <p>If called multiple times, it always returns the same object depending on the {@code * purpose}. It does not check that the list of inputs is identical. In contrast to other * middleman methods, this one also returns an object if the list of inputs is empty. * * <p>Note: there's no need to synchronize this method; the only use of a field is via a call to * another synchronized method (getArtifact()). */ public Artifact createMiddlemanAllowMultiple( ActionRegistry registry, ActionOwner owner, PathFragment packageDirectory, String purpose, Iterable<Artifact> inputs, Root middlemanDir) { String escapedPackageDirectory = Actions.escapedPath(packageDirectory.getPathString()); PathFragment stampName = new PathFragment( "_middlemen/" + (purpose.startsWith(escapedPackageDirectory) ? purpose : (escapedPackageDirectory + purpose))); Artifact stampFile = artifactFactory.getDerivedArtifact(stampName, middlemanDir, actionRegistry.getOwner()); MiddlemanAction.create( registry, owner, inputs, stampFile, purpose, MiddlemanType.AGGREGATING_MIDDLEMAN); return stampFile; }