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

gu.sql2java.generator.RunMojo Maven / Gradle / Ivy

There is a newer version: 5.2.0
Show newest version
package gu.sql2java.generator;

import static gu.sql2java.generator.GeneratorConstants.*;

import java.io.File;
import java.util.List;

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;

import com.google.common.base.Joiner;
import com.google.common.collect.Lists;

/**
 * maven 插件
* 根据提供的配置文件,生成数据库操作代码(java),等同于执行{@link gu.sql2java.generator.Generator#main(String[])} * * @author guyadong * */ @Mojo(name = "generate", requiresProject = false) public class RunMojo extends AbstractMojo { /** * properties file path for configuration */ @Parameter(property = "sql2java.propfile",required=true) private File propFile; /** * class path for lookup JDBC driver,split by ';' on Windows or ':' on Linux */ @Parameter(property = "sql2java.classpath",defaultValue="") private List classpath; /** * show stack trace on error ,default: false */ @Parameter(property = "sql2java.trace",defaultValue="false") private boolean trace = false; public RunMojo() { } @Override public void execute() throws MojoExecutionException, MojoFailureException { List args = Lists.newLinkedList(); args.add("--" + PROPFILE_OPTION_LONG); args.add(propFile.getAbsolutePath()); if(!classpath.isEmpty()){ args.add("--" + CLASSPATH_OPTION_LONG); args.add(Joiner.on(';').join(classpath)); } if(trace){ args.add("--" + TRACE_OPTION_LONG); } Generator.main(args.toArray(new String[args.size()])); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy