throws MojoExecutionException {
final Map<Artifact, File> fromTo = compute(artifacts, resourceTargetFile(moduleDirectory));
final Map<File, Future<String>> targetHashes = sha1async(fromTo.values());
final Pool pool = Resources.getPoolHandle();
final ExecutorService executor = pool.aquireExec();
try {
return collect(ImmutableList.copyOf(transform(fromTo.entrySet(),
new Function<Entry<Artifact, File>, Future<String>>() {
@Override
public Future<String> apply(final Entry<Artifact, File> e) {
final Artifact a = e.getKey();
final File src = a.getFile();
final File target = e.getValue();
final Future<String> targetHash = targetHashes.get(target);
checkState(src != null, "missing file for %s", a);
return executor.submit(conditionalCopy(src, target, targetHash));
}
})));
} catch (final ComputationException e) {
throw new MojoExecutionException("failed to copy artifacts", e.getCause());
} finally {
pool.releaseExec(executor);
}
}