@Override public XmlOutput generate() { JApiCmpXmlRoot jApiCmpXmlRoot = createRootElement(jApiClasses, options); //analyzeJpaAnnotations(jApiCmpXmlRoot, jApiClasses); filterClasses(jApiClasses, options); return createXmlDocumentAndSchema(options, jApiCmpXmlRoot); }
@Deprecated public XmlOutputGenerator(List<JApiClass> jApiClasses, Options options, boolean createSchemaFile) { super(options, jApiClasses); this.xmlOutputGeneratorOptions = new XmlOutputGeneratorOptions(); this.xmlOutputGeneratorOptions.setCreateSchemaFile(createSchemaFile); }
private JApiCmpXmlRoot createRootElement(List<JApiClass> jApiClasses, Options options) { JApiCmpXmlRoot jApiCmpXmlRoot = new JApiCmpXmlRoot(); jApiCmpXmlRoot.setOldJar(options.joinOldArchives()); jApiCmpXmlRoot.setNewJar(options.joinNewArchives()); jApiCmpXmlRoot.setOldVersion(options.joinOldVersions()); jApiCmpXmlRoot.setNewVersion(options.joinNewVersions()); jApiCmpXmlRoot.setClasses(jApiClasses); jApiCmpXmlRoot.setAccessModifier(options.getAccessModifier().name()); jApiCmpXmlRoot.setOnlyModifications(options.isOutputOnlyModifications()); jApiCmpXmlRoot.setOnlyBinaryIncompatibleModifications(options.isOutputOnlyBinaryIncompatibleModifications()); jApiCmpXmlRoot.setPackagesInclude(filtersAsString(options.getIncludes(), true)); jApiCmpXmlRoot.setPackagesExclude(filtersAsString(options.getExcludes(), false)); jApiCmpXmlRoot.setIgnoreMissingClasses(options.getIgnoreMissingClasses().isIgnoreAllMissingClasses()); jApiCmpXmlRoot.setIgnoreMissingClassesByRegularExpressions(regExAsString(options.getIgnoreMissingClasses().getIgnoreMissingClassRegularExpression())); if (xmlOutputGeneratorOptions.getTitle().isPresent()) { jApiCmpXmlRoot.setTitle(xmlOutputGeneratorOptions.getTitle().get()); } jApiCmpXmlRoot.setSemanticVersioning(xmlOutputGeneratorOptions.getSemanticVersioningInformation()); return jApiCmpXmlRoot; }
XmlOutputGeneratorOptions xmlOutputGeneratorOptions = new XmlOutputGeneratorOptions(); xmlOutputGeneratorOptions.setCreateSchemaFile(true); xmlOutputGeneratorOptions.setSemanticVersioningInformation(semverOut.generate()); XmlOutputGenerator xmlGenerator = new XmlOutputGenerator(jApiClasses, options, xmlOutputGeneratorOptions); try (XmlOutput xmlOutput = xmlGenerator.generate()) { XmlOutputGenerator.writeToFiles(options, xmlOutput); } catch (Exception e) { throw new JApiCmpException(JApiCmpException.Reason.IoException, "Could not close output streams: " + e.getMessage(), e);
private XmlOutput generateXmlOutput(List<JApiClass> jApiClasses, File jApiCmpBuildDir, Options options, MavenParameters mavenParameters, PluginParameters pluginParameters) throws IOException { String filename = createFilename(mavenParameters); if (!skipXmlReport(pluginParameters)) { options.setXmlOutputFile(Optional.of(jApiCmpBuildDir.getCanonicalPath() + File.separator + filename + ".xml")); } if (!skipHtmlReport(pluginParameters)) { options.setHtmlOutputFile(Optional.of(jApiCmpBuildDir.getCanonicalPath() + File.separator + filename + ".html")); } SemverOut semverOut = new SemverOut(options, jApiClasses); XmlOutputGeneratorOptions xmlOutputGeneratorOptions = new XmlOutputGeneratorOptions(); xmlOutputGeneratorOptions.setCreateSchemaFile(true); xmlOutputGeneratorOptions.setSemanticVersioningInformation(semverOut.generate()); if (pluginParameters.getParameterParam() != null) { String optionalTitle = pluginParameters.getParameterParam().getHtmlTitle(); xmlOutputGeneratorOptions.setTitle(optionalTitle!=null ?optionalTitle :options.getDifferenceDescription()); } XmlOutputGenerator xmlGenerator = new XmlOutputGenerator(jApiClasses, options, xmlOutputGeneratorOptions); return xmlGenerator.generate(); }
XmlOutputGeneratorOptions xmlOptions = new XmlOutputGeneratorOptions(); XmlOutputGenerator xmlOutputGenerator = new XmlOutputGenerator(jApiClasses, options, xmlOptions); XmlOutput xmlOutput = xmlOutputGenerator.generate(); XmlOutputGenerator.writeToFiles(options, xmlOutput);
private XmlOutput createXmlDocumentAndSchema(Options options, JApiCmpXmlRoot jApiCmpXmlRoot) { XmlOutput xmlOutput = new XmlOutput(); xmlOutput.setJApiCmpXmlRoot(jApiCmpXmlRoot); ByteArrayOutputStream xmlBaos = null; InputStream styleSheetAsInputStream = null; marshaller.marshal(jApiCmpXmlRoot, xmlBaos); if (options.getXmlOutputFile().isPresent()) { xmlOutput.setXmlOutputStream(Optional.of(xmlBaos)); if (xmlOutputGeneratorOptions.isCreateSchemaFile()) { final File xmlFile = new File(options.getXmlOutputFile().get()); SchemaOutputResolver outputResolver = new SchemaOutputResolver() { String xsltAsString = integrateStylesheetIntoXslt(xsltAsInputStream, styleSheetAsInputStream); Transformer transformer = transformerFactory.newTransformer(new StreamSource(new StringReader(xsltAsString))); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlBaos.toByteArray()); ByteArrayOutputStream htmlOutputStream = new ByteArrayOutputStream(); transformer.transform(new StreamSource(byteArrayInputStream), new StreamResult(htmlOutputStream)); xmlOutput.setHtmlOutputStream(Optional.of(htmlOutputStream));
public static List<File> writeToFiles(Options options, XmlOutput xmlOutput) { List<File> filesWritten = new ArrayList<>(); try { if (xmlOutput.getXmlOutputStream().isPresent() && options.getXmlOutputFile().isPresent()) { File xmlFile = new File(options.getXmlOutputFile().get()); try (FileOutputStream fos = new FileOutputStream(xmlFile)) { ByteArrayOutputStream outputStream = xmlOutput.getXmlOutputStream().get(); outputStream.writeTo(fos); filesWritten.add(xmlFile); if (xmlOutput.getHtmlOutputStream().isPresent() && options.getHtmlOutputFile().isPresent()) { File htmlFile = new File(options.getHtmlOutputFile().get()); try (FileOutputStream fos = new FileOutputStream(htmlFile)) { ByteArrayOutputStream outputStream = xmlOutput.getHtmlOutputStream().get(); outputStream.writeTo(fos); filesWritten.add(htmlFile); xmlOutput.close(); } catch (Exception e) { LOGGER.log(Level.FINE, "Failed to close XML file: " + e.getLocalizedMessage(), e);
XmlOutput xmlOutput = generateXmlOutput(jApiClasses, jApiCmpBuildDir, options, mavenParameters, pluginParameters); if (pluginParameters.isWriteToFiles()) { List<File> filesWritten = XmlOutputGenerator.writeToFiles(options, xmlOutput); for (File file : filesWritten) { getLog().info("Written file '" + file.getAbsolutePath() + "'.");
if (xmlOutputOptional.isPresent()) { XmlOutput xmlOutput = xmlOutputOptional.get(); if (xmlOutput.getHtmlOutputStream().isPresent()) { ByteArrayOutputStream htmlOutputStream = xmlOutput.getHtmlOutputStream().get(); String htmlString = htmlOutputStream.toString("UTF-8"); htmlString = htmlString.replaceAll("</?html>", "");
XmlOutputGeneratorOptions xmlOutputGeneratorOptions = new XmlOutputGeneratorOptions(); xmlOutputGeneratorOptions.setCreateSchemaFile(true); xmlOutputGeneratorOptions.setSemanticVersioningInformation(semverOut.generate()); XmlOutputGenerator xmlGenerator = new XmlOutputGenerator(jApiClasses, options, xmlOutputGeneratorOptions); try (XmlOutput xmlOutput = xmlGenerator.generate()) { XmlOutputGenerator.writeToFiles(options, xmlOutput); } catch (Exception e) { throw new JApiCmpException(JApiCmpException.Reason.IoException, "Could not close output streams: " + e.getMessage(), e);
private JApiCmpXmlRoot createRootElement(List<JApiClass> jApiClasses, Options options) { JApiCmpXmlRoot jApiCmpXmlRoot = new JApiCmpXmlRoot(); jApiCmpXmlRoot.setOldJar(options.joinOldArchives()); jApiCmpXmlRoot.setNewJar(options.joinNewArchives()); jApiCmpXmlRoot.setOldVersion(options.joinOldVersions()); jApiCmpXmlRoot.setNewVersion(options.joinNewVersions()); jApiCmpXmlRoot.setClasses(jApiClasses); jApiCmpXmlRoot.setAccessModifier(options.getAccessModifier().name()); jApiCmpXmlRoot.setOnlyModifications(options.isOutputOnlyModifications()); jApiCmpXmlRoot.setOnlyBinaryIncompatibleModifications(options.isOutputOnlyBinaryIncompatibleModifications()); jApiCmpXmlRoot.setPackagesInclude(filtersAsString(options.getIncludes(), true)); jApiCmpXmlRoot.setPackagesExclude(filtersAsString(options.getExcludes(), false)); jApiCmpXmlRoot.setIgnoreMissingClasses(options.getIgnoreMissingClasses().isIgnoreAllMissingClasses()); jApiCmpXmlRoot.setIgnoreMissingClassesByRegularExpressions(regExAsString(options.getIgnoreMissingClasses().getIgnoreMissingClassRegularExpression())); if (xmlOutputGeneratorOptions.getTitle().isPresent()) { jApiCmpXmlRoot.setTitle(xmlOutputGeneratorOptions.getTitle().get()); } jApiCmpXmlRoot.setSemanticVersioning(xmlOutputGeneratorOptions.getSemanticVersioningInformation()); return jApiCmpXmlRoot; }
@Deprecated public XmlOutputGenerator(List<JApiClass> jApiClasses, Options options, boolean createSchemaFile) { super(options, jApiClasses); this.xmlOutputGeneratorOptions = new XmlOutputGeneratorOptions(); this.xmlOutputGeneratorOptions.setCreateSchemaFile(createSchemaFile); }
private XmlOutput createXmlDocumentAndSchema(Options options, JApiCmpXmlRoot jApiCmpXmlRoot) { XmlOutput xmlOutput = new XmlOutput(); xmlOutput.setJApiCmpXmlRoot(jApiCmpXmlRoot); ByteArrayOutputStream xmlBaos = null; InputStream styleSheetAsInputStream = null; marshaller.marshal(jApiCmpXmlRoot, xmlBaos); if (options.getXmlOutputFile().isPresent()) { xmlOutput.setXmlOutputStream(Optional.of(xmlBaos)); if (xmlOutputGeneratorOptions.isCreateSchemaFile()) { final File xmlFile = new File(options.getXmlOutputFile().get()); SchemaOutputResolver outputResolver = new SchemaOutputResolver() { String xsltAsString = integrateStylesheetIntoXslt(xsltAsInputStream, styleSheetAsInputStream); Transformer transformer = transformerFactory.newTransformer(new StreamSource(new StringReader(xsltAsString))); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlBaos.toByteArray()); ByteArrayOutputStream htmlOutputStream = new ByteArrayOutputStream(); transformer.transform(new StreamSource(byteArrayInputStream), new StreamResult(htmlOutputStream)); xmlOutput.setHtmlOutputStream(Optional.of(htmlOutputStream));
public static List<File> writeToFiles(Options options, XmlOutput xmlOutput) { List<File> filesWritten = new ArrayList<>(); try { if (xmlOutput.getXmlOutputStream().isPresent() && options.getXmlOutputFile().isPresent()) { File xmlFile = new File(options.getXmlOutputFile().get()); try (FileOutputStream fos = new FileOutputStream(xmlFile)) { ByteArrayOutputStream outputStream = xmlOutput.getXmlOutputStream().get(); outputStream.writeTo(fos); filesWritten.add(xmlFile); if (xmlOutput.getHtmlOutputStream().isPresent() && options.getHtmlOutputFile().isPresent()) { File htmlFile = new File(options.getHtmlOutputFile().get()); try (FileOutputStream fos = new FileOutputStream(htmlFile)) { ByteArrayOutputStream outputStream = xmlOutput.getHtmlOutputStream().get(); outputStream.writeTo(fos); filesWritten.add(htmlFile); xmlOutput.close(); } catch (Exception e) { LOGGER.log(Level.FINE, "Failed to close XML file: " + e.getLocalizedMessage(), e);
@Override public XmlOutput generate() { JApiCmpXmlRoot jApiCmpXmlRoot = createRootElement(jApiClasses, options); //analyzeJpaAnnotations(jApiCmpXmlRoot, jApiClasses); filterClasses(jApiClasses, options); return createXmlDocumentAndSchema(options, jApiCmpXmlRoot); }
XmlOutputGeneratorOptions xmlOutputGeneratorOptions = new XmlOutputGeneratorOptions(); xmlOutputGeneratorOptions.setCreateSchemaFile(true); xmlOutputGeneratorOptions.setSemanticVersioningInformation(semverOut.generate()); XmlOutputGenerator xmlGenerator = new XmlOutputGenerator(jApiClasses, options, xmlOutputGeneratorOptions); try (XmlOutput xmlOutput = xmlGenerator.generate()) { XmlOutputGenerator.writeToFiles(options, xmlOutput); } catch (Exception e) { throw new BuildException("Could not close output streams: " + e.getMessage(), e);