use of org.apache.tools.ant.util.IdentityMapper in project ant by apache.
the class Image method execute.
/**
* Executes the Task.
* @throws BuildException on error.
*/
@Override
public void execute() throws BuildException {
validateAttributes();
try {
File dest = (destDir != null) ? destDir : srcDir;
int writeCount = 0;
// build mapper
final FileNameMapper mapper = mapperElement == null ? new IdentityMapper() : mapperElement.getImplementation();
// deal with specified srcDir
if (srcDir != null) {
writeCount += processDir(srcDir, super.getDirectoryScanner(srcDir).getIncludedFiles(), dest, mapper);
}
// deal with the filesets
for (FileSet fs : filesets) {
writeCount += processDir(fs.getDir(getProject()), fs.getDirectoryScanner(getProject()).getIncludedFiles(), dest, mapper);
}
if (writeCount > 0) {
log("Processed " + writeCount + (writeCount == 1 ? " image." : " images."));
}
} catch (Exception err) {
log(StringUtils.getStackTrace(err), Project.MSG_ERR);
throw new BuildException(err.getMessage());
}
}
use of org.apache.tools.ant.util.IdentityMapper in project ant by apache.
the class MappedResourceCollection method getCollection.
private Collection<Resource> getCollection() {
FileNameMapper m = mapper == null ? new IdentityMapper() : mapper.getImplementation();
Stream<MappedResource> stream;
if (enableMultipleMappings) {
stream = nested.stream().flatMap(r -> Stream.of(m.mapFileName(r.getName())).filter(Objects::nonNull).map(MergingMapper::new).map(mm -> new MappedResource(r, mm)));
} else {
stream = nested.stream().map(r -> new MappedResource(r, m));
}
return stream.collect(Collectors.toList());
}
Aggregations