io.github.pmckeown.dependencytrack.finding.report.XmlReportWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependency-track-maven-plugin Show documentation
Show all versions of dependency-track-maven-plugin Show documentation
Maven plugin to integrate with a Dependency Track server to submit dependency manifests and gather project metrics.
package io.github.pmckeown.dependencytrack.finding.report;
import io.github.pmckeown.dependencytrack.DependencyTrackException;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.File;
@Singleton
class XmlReportWriter {
private FindingsReportMarshallerService marshallerService;
@Inject
XmlReportWriter(FindingsReportMarshallerService marshallerService) {
this.marshallerService = marshallerService;
}
void write(File buildDirectory, FindingsReport findingsReport) throws DependencyTrackException {
try {
Marshaller marshaller = marshallerService.getMarshaller();
File outputFile = getFile(buildDirectory);
marshaller.marshal(findingsReport, outputFile);
} catch (JAXBException ex) {
throw new DependencyTrackException("Error occurred while generating XML report", ex);
}
}
private File getFile(File buildDirectory) {
if (buildDirectory != null && !buildDirectory.exists()) {
buildDirectory.mkdir();
}
return new File(buildDirectory, FindingsReportConstants.XML_REPORT_FILENAME);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy