001package gu.sql2java.generator; 002 003import java.io.File; 004import java.net.URL; 005import org.apache.maven.plugin.AbstractMojo; 006 007import org.apache.maven.plugin.MojoExecutionException; 008import org.apache.maven.plugin.MojoFailureException; 009import org.apache.maven.plugins.annotations.Mojo; 010import org.apache.maven.plugins.annotations.Parameter; 011 012import net.gdface.utils.FaceUtilits; 013 014/** 015 * maven 插件<br> 016 * 输出的默认配置文件 017 * 018 * @author guyadong 019 * 020 */ 021@Mojo(name = "help", requiresProject = false) 022public class HelpMojo extends AbstractMojo { 023 /** 024 * properties file output path<br> 025 * output to "standard" output stream if absent 026 */ 027 @Parameter(property = "sql2java.output") 028 private File outputFile; 029 030 public HelpMojo() { 031 } 032 033 @Override 034 public void execute() throws MojoExecutionException, MojoFailureException { 035 036 try { 037 URL url = HelpMojo.class.getResource("/sql2java.properties"); 038 byte[] content = FaceUtilits.getBytes(url); 039 if(outputFile != null){ 040 getLog().info("OUTPUT PROPRETIES TO " + outputFile); 041 FaceUtilits.saveBytes(content, outputFile, true); 042 }else{ 043 getLog().info("=========SQL2JAVA PROPERTIES============"); 044 System.out.println(new String(content,"UTF-8")); 045 getLog().info("========COMMAND LINE OPTIONS============="); 046 Generator.main("--help"); 047 } 048 } catch (Exception e) { 049 throw new MojoExecutionException(e.getMessage(),e); 050 } 051 } 052}