![JAR search and dependency download from the Maven repository](/logo.png)
org.linuxstuff.mojo.licensing.CollectReportsMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of licensing-maven-plugin Show documentation
Show all versions of licensing-maven-plugin Show documentation
Forked from http://github.com/idcmp/licensing-maven-plugin
package org.linuxstuff.mojo.licensing;
import java.io.File;
import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.linuxstuff.mojo.licensing.model.ArtifactWithLicenses;
import org.linuxstuff.mojo.licensing.model.LicensingReport;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.StaxDriver;
/**
* @goal collect-reports
* @requiresProject true
* @threadSafe
* @aggregator
*/
public class CollectReportsMojo extends AbstractLicensingMojo {
/**
* Maven ProjectHelper.
*
* @component
* @readonly
*/
private MavenProjectHelper projectHelper;
/**
* The projects in the reactor for aggregation report.
*
* @parameter expression="${reactorProjects}"
* @readonly
* @required
*/
private List reactorProjects;
private LicensingReport report;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
readLicensingRequirements();
report = new LicensingReport();
XStream xstream = new XStream(new StaxDriver());
xstream.processAnnotations(ArtifactWithLicenses.class);
xstream.processAnnotations(LicensingReport.class);
for (MavenProject p : reactorProjects) {
File licenseXml = new File(p.getBuild().getDirectory(), thirdPartyLicensingFilename);
if (licenseXml.canRead()) {
LicensingReport artifactReport = (LicensingReport) xstream.fromXML(licenseXml);
getLog().debug("Successfully turned " + licenseXml + " into " + artifactReport);
report.combineWith(artifactReport);
} else {
getLog().debug("No report file found at: " + licenseXml.getAbsolutePath());
}
}
File outputFile = new File(project.getBuild().getDirectory(), aggregatedThirdPartyLicensingFilename);
report.writeReport(outputFile);
projectHelper.attachArtifact(project, outputFile, "aggregated-third-party-licensing");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy