private void generateXml(IvyNode[] dependencies, Map moduleRevToArtifactsMap,
Map artifactsToCopy) {
try {
FileOutputStream fileOuputStream = new FileOutputStream(tofile);
try {
TransformerHandler saxHandler = createTransformerHandler(fileOuputStream);
saxHandler.startDocument();
saxHandler.startElement(null, "modules", "modules", new AttributesImpl());
for (int i = 0; i < dependencies.length; i++) {
IvyNode dependency = dependencies[i];
if (dependency.getModuleRevision() == null || dependency.isCompletelyEvicted()) {
continue;
}
startModule(saxHandler, dependency);
Set artifactsOfModuleRev = (Set) moduleRevToArtifactsMap.get(dependency
.getModuleRevision().getId());
if (artifactsOfModuleRev != null) {
for (Iterator iter = artifactsOfModuleRev.iterator(); iter.hasNext();) {
ArtifactDownloadReport artifact = (ArtifactDownloadReport) iter.next();
RepositoryCacheManager cache = dependency.getModuleRevision()
.getArtifactResolver().getRepositoryCacheManager();
startArtifact(saxHandler, artifact.getArtifact());
writeOriginLocationIfPresent(cache, saxHandler, artifact);
writeCacheLocationIfPresent(cache, saxHandler, artifact);
Set artifactDestPaths = (Set) artifactsToCopy.get(artifact);
for (Iterator iterator = artifactDestPaths.iterator(); iterator
.hasNext();) {
String artifactDestPath = (String) iterator.next();
writeRetrieveLocation(saxHandler, artifactDestPath);
}
saxHandler.endElement(null, "artifact", "artifact");
}
}
saxHandler.endElement(null, "module", "module");
}
saxHandler.endElement(null, "modules", "modules");
saxHandler.endDocument();
} finally {
fileOuputStream.close();
}
} catch (SAXException e) {
throw new BuildException("impossible to generate report", e);