com.kribblo.github.mojo.ProjectInfoJsonWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of project-info-maven-plugin Show documentation
Show all versions of project-info-maven-plugin Show documentation
Light-weight project information extractor, for reporting optionally filtered dependencies and some other things on a project. Useful for collecting version information and who depends on who in an environment with multiple servers, perhaps many many small services.
The newest version!
package com.kribblo.github.mojo;
import com.google.gson.*;
import org.apache.maven.plugin.MojoExecutionException;
import java.io.*;
public class ProjectInfoJsonWriter {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private final File outputFile;
public ProjectInfoJsonWriter(File outputFile) {
this.outputFile = outputFile;
}
public void writeJsonToFile(ProjectInfo projectInfo) throws MojoExecutionException {
FileWriter fileWriter;
try {
fileWriter = new FileWriter(outputFile);
GSON.toJson(projectInfo, fileWriter);
fileWriter.close();
} catch (IOException | JsonIOException e) {
throw new MojoExecutionException("Could not write to file: " + outputFile, e);
}
}
}