package com.internetitem.maven.writePropertiesFile;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.Properties;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

@Mojo(name = "write-properties-file")
public class WritePropertiesFileMojo extends AbstractMojo {

	@Parameter(property = "outputFile", required = true)
	private File outputFile;

	@Parameter(property = "properties", required = true)
	private Properties properties;

	public void execute() throws MojoExecutionException, MojoFailureException {
		getLog().info("Saving properties to file " + outputFile.getAbsolutePath());
		FileOutputStream out = null;
		try {
			out = new FileOutputStream(outputFile);
			OutputStreamWriter writer = new OutputStreamWriter(out, Charset.forName("UTF-8"));
			properties.store(writer, "Generated by Maven");
			writer.close();
			out.close();
		} catch (IOException e) {
			throw new MojoFailureException("Unable to save properties to file " + outputFile.getAbsolutePath() + ": " + e.getMessage(), e);
		} finally {
			if (out != null) {
				try {
					out.close();
				} catch (Exception e) {
					// Ignore
				}
			}
		}
	}

}

@@ -485,16 +485,105 @@
 meter;%0A%0A
+/**%0A * Create a Java Properties file%0A * %0A * @author Adam Batkin %3Cadam@batkin.net%3E%0A *%0A */%0A
 @Mojo(na
@@ -673,16 +673,66 @@
 Mojo %7B%0A%0A
+%09/**%0A%09 * File where the properties are saved%0A%09 */%0A
 %09@Parame
@@ -804,16 +804,49 @@
 tFile;%0A%0A
+%09/**%0A%09 * Properties to save%0A%09 */%0A
 %09@Parame

add javadoc