package org.jerrymouse.gaes.mavenPlugin.mojos;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

/**
 * 
 * @goal archetype
 */
public class ArchetypeMojo extends AbstractMojo {

	@Override
	public void execute() throws MojoExecutionException, MojoFailureException {

		try {
			Runtime rt = Runtime.getRuntime();
			Process proc;
			proc = rt
					.exec("mvn archetype:generat/gaestation.appspot.com/repository/archetype-catalog.xml -DarchetypeRepository=http://gaestation.appspot.com/repository");
			InputStream stderr = proc.getInputStream();
			BufferedReader br = new BufferedReader(
					new InputStreamReader(stderr));
			String line = null;
			while ((line = br.readLine()) != null)
				System.out.println(line);
			int exitVal = proc.waitFor();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
