@Override public void generate(final File reportsDir, final VersionManagerSession session) throws VManException { Map<VersionlessProjectKey, Set<Plugin>> missingPlugins = session.getUnmanagedPluginRefs(); if (missingPlugins.isEmpty()) { return; } Element plugins = new Element("plugins"); for (Map.Entry<VersionlessProjectKey, Set<Plugin>> pluginsEntry : missingPlugins.entrySet()) { if (plugins.getContentSize() > 0) { plugins.addContent("\n\n"); } plugins.addContent(new Comment("START: " + pluginsEntry.getKey())); for (Plugin dep : pluginsEntry.getValue()) { Element d = new Element("plugin"); plugins.addContent(d); d.addContent(new Element("groupId").setText(dep.getGroupId())); d.addContent(new Element("artifactId").setText(dep.getArtifactId())); d.addContent(new Element("version").setText(dep.getVersion())); } plugins.addContent(new Comment("END: " + pluginsEntry.getKey())); } Element build = new Element("build"); build.addContent(new Element("pluginManagement").setContent(plugins)); Document doc = new Document(build); Format fmt = Format.getPrettyFormat(); fmt.setIndent(" "); fmt.setTextMode(TextMode.PRESERVE); XMLOutputter output = new XMLOutputter(fmt); File report = new File(reportsDir, ID + ".xml"); FileWriter writer = null; try { reportsDir.mkdirs(); writer = new FileWriter(report); output.output(doc, writer); } catch (IOException e) { throw new VManException("Failed to generate %s report! Error: %s", e, ID, e.getMessage()); } finally { closeQuietly(writer); } }
@Override public void generate(final File reportsDir, final VersionManagerSession session) throws VManException { final Map<VersionlessProjectKey, Set<Dependency>> missingDependencies = session.getMissingDependencies(); if (missingDependencies.isEmpty()) { return; } final Element deps = new Element("dependencies"); for (final Map.Entry<VersionlessProjectKey, Set<Dependency>> depsEntry : missingDependencies.entrySet()) { if (deps.getContentSize() > 0) { deps.addContent("\n\n"); } deps.addContent(new Comment("START: " + depsEntry.getKey())); for (final Dependency dep : depsEntry.getValue()) { final Element d = new Element("dependency"); deps.addContent(d); d.addContent(new Element("groupId").setText(dep.getGroupId())); d.addContent(new Element("artifactId").setText(dep.getArtifactId())); d.addContent(new Element("version").setText(dep.getVersion())); if (isNotEmpty(dep.getType()) && !"jar".equals(dep.getType())) { d.addContent(new Element("type").setText(dep.getType())); } if (isNotEmpty(dep.getClassifier())) { d.addContent(new Element("classifier").setText(dep.getClassifier())); } // if ( dep.isOptional() ) // { // d.addContent( new Element( "optional" ).setText( Boolean.toString( true ) ) ); // } // // if ( dep.getExclusions() != null && !dep.getExclusions().isEmpty() ) // { // Element ex = new Element( "exclusions" ); // d.addContent( ex ); // // for ( Exclusion exclusion : dep.getExclusions() ) // { // ex.addContent( new Element( "groupId" ).setText( exclusion.getGroupId() ) ); // ex.addContent( new Element( "artifactId" ).setText( exclusion.getArtifactId() ) ); // } // } } deps.addContent(new Comment("END: " + depsEntry.getKey())); } final Element dm = new Element("dependencyManagement"); dm.setContent(deps); final Document doc = new Document(dm); final Format fmt = Format.getPrettyFormat(); fmt.setIndent(" "); fmt.setTextMode(TextMode.PRESERVE); final XMLOutputter output = new XMLOutputter(fmt); final File report = new File(reportsDir, ID); FileWriter writer = null; try { reportsDir.mkdirs(); writer = new FileWriter(report); output.output(doc, writer); } catch (final IOException e) { throw new VManException("Failed to generate %s report! Error: %s", e, ID, e.getMessage()); } finally { closeQuietly(writer); } }