All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kribblo.github.mojo.ProjectInfoJsonWriter Maven / Gradle / Ivy

Go to download

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);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy