use of org.apache.ivy.plugins.report.XmlReportOutputter in project ant-ivy by apache.
the class IvyRepositoryReport method doExecute.
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (xsl && xslFile == null) {
throw new BuildException("xsl file is mandatory when using xsl generation");
}
if (module == null && PatternMatcher.EXACT.equals(matcher)) {
throw new BuildException("no module name provided for ivy repository graph task: " + "It can either be set explicitly via the attribute 'module' or " + "via 'ivy.module' property or a prior call to <resolve/>");
} else if (module == null && !PatternMatcher.EXACT.equals(matcher)) {
module = PatternMatcher.ANY_EXPRESSION;
}
ModuleRevisionId moduleRevisionId = ModuleRevisionId.newInstance(organisation, module, revision);
try {
ModuleRevisionId criteria = (revision == null) || settings.getVersionMatcher().isDynamic(moduleRevisionId) ? new ModuleRevisionId(new ModuleId(organisation, module), branch, "*") : new ModuleRevisionId(new ModuleId(organisation, module), branch, revision);
ModuleRevisionId[] mrids = ivy.listModules(criteria, settings.getMatcher(matcher));
// replace all found revisions with the original requested revision
Set<ModuleRevisionId> modules = new HashSet<>();
for (ModuleRevisionId mrid : mrids) {
modules.add(ModuleRevisionId.newInstance(mrid, revision));
}
mrids = modules.toArray(new ModuleRevisionId[modules.size()]);
ModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(mrids, true, false);
String resolveId = ResolveOptions.getDefaultResolveId(md);
ResolveReport report = ivy.resolve(md, new ResolveOptions().setResolveId(resolveId).setValidate(doValidate(settings)));
ResolutionCacheManager cacheMgr = getIvyInstance().getResolutionCacheManager();
new XmlReportOutputter().output(report, cacheMgr, new ResolveOptions());
if (graph) {
gengraph(cacheMgr, md.getModuleRevisionId().getOrganisation(), md.getModuleRevisionId().getName());
}
if (dot) {
gendot(cacheMgr, md.getModuleRevisionId().getOrganisation(), md.getModuleRevisionId().getName());
}
if (xml) {
FileUtil.copy(cacheMgr.getConfigurationResolveReportInCache(resolveId, "default"), new File(getTodir(), outputname + ".xml"), null);
}
if (xsl) {
genreport(cacheMgr, md.getModuleRevisionId().getOrganisation(), md.getModuleRevisionId().getName());
}
} catch (Exception e) {
throw new BuildException("impossible to generate graph for " + moduleRevisionId + ": " + e, e);
}
}
Aggregations