<commit_before>package me.ezjs.generator;

import me.ezjs.generator.mybatis.api.MyBatisGenerator;
import me.ezjs.generator.mybatis.config.*;
import me.ezjs.generator.mybatis.config.xml.ConfigurationParser;
import me.ezjs.generator.mybatis.exception.InvalidConfigurationException;
import me.ezjs.generator.mybatis.exception.XMLParserException;
import me.ezjs.generator.mybatis.internal.DefaultShellCallback;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLDecoder;
import java.sql.SQLException;
import java.util.*;

/**
 * Created by zero-mac on 17/8/11.
 */
public class CoreGenerator {

    private final static String DEFAULT_CONTEXT = "default";

    private static final String MysqlHost = "mysql.host";
    private static final String MysqlDB = "mysql.db";
    private static final String MysqlPort = "mysql.port";
    private static final String MysqlUser = "mysql.user";
    private static final String MysqlPass = "<PASSWORD>";

    private static final String PKG_PREFIX = "me.ezjs.";//默认包的前缀,暂不支持修改
    private static final String targetModule = "target.module";
    private static final String targetDir = "target.dir";//目标目录,默认设置为当前执行的目录,即jar包(执行文件)的目录

    private static final String TABLES_KEY = "tables";

    private static Map<String, List<String>> cmdParams;

    public static void main(String[] args) throws IOException, XMLParserException, InvalidConfigurationException, SQLException, InterruptedException {

        parseCmdArgs(args);

        List<String> warnings = new ArrayList<String>();
        boolean overwrite = true;
        //指定 逆向工程配置文件
        InputStream stream = ClassLoader.getSystemResourceAsStream("generatorConfig.xml");

        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(stream);

        Context defaultContext = config.getContext(DEFAULT_CONTEXT);

        //mysql
        JDBCConnectionConfiguration jdbcConnectionConfiguration = defaultContext.getJdbcConnectionConfiguration();
        String mysqlHost = getParam(MysqlHost, "localhost");
        String mysqlPort = getParam(MysqlPort, "3306");
        String mysqlDb = getParam(MysqlDB);
        String mysqlURL = "jdbc:mysql://" + mysqlHost + ":" + mysqlPort + "/" + mysqlDb + "?useUnicode=true&useSSL=false";
        jdbcConnectionConfiguration.setConnectionURL(mysqlURL);
        jdbcConnectionConfiguration.setUserId(getParam(MysqlUser, "root"));
        jdbcConnectionConfiguration.setPassword(getParam(MysqlPass));
//defaultContext.setJdbcConnectionConfiguration(jdbcConnectionConfiguration);

        //target
        JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = defaultContext.getJavaModelGeneratorConfiguration();
        javaModelGeneratorConfiguration.setTargetPackage(PKG_PREFIX + getParam(targetModule));
        javaModelGeneratorConfiguration.setTargetProject(getParam(targetDir, getRunTimePath()));
//defaultContext.setJavaModelGeneratorConfiguration(javaModelGeneratorConfiguration);


        List<String> tables = getParamList(TABLES_KEY);

        List<TableConfiguration> tcs = defaultContext.getTableConfigurations();
        while (tcs.size() > 0) {<commit_msg>printout targetDir<commit_after>package me.ezjs.generator;

import me.ezjs.generator.mybatis.api.MyBatisGenerator;
import me.ezjs.generator.mybatis.config.*;
import me.ezjs.generator.mybatis.config.xml.ConfigurationParser;
import me.ezjs.generator.mybatis.exception.InvalidConfigurationException;
import me.ezjs.generator.mybatis.exception.XMLParserException;
import me.ezjs.generator.mybatis.internal.DefaultShellCallback;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLDecoder;
import java.sql.SQLException;
import java.util.*;

/**
 * Created by zero-mac on 17/8/11.
 */
public class CoreGenerator {

    private final static String DEFAULT_CONTEXT = "default";

    private static final String MysqlHost = "mysql.host";
    private static final String MysqlDB = "mysql.db";
    private static final String MysqlPort = "mysql.port";
    private static final String MysqlUser = "mysql.user";
    private static final String MysqlPass = "mysql.pass";

    private static final String PKG_PREFIX = "me.ezjs.";//默认包的前缀,暂不支持修改
    private static final String targetModule = "target.module";
    private static final String targetDir = "target.dir";//目标目录,默认设置为当前执行的目录,即jar包(执行文件)的目录

    private static final String TABLES_KEY = "tables";

    private static Map<String, List<String>> cmdParams;

    public static void main(String[] args) throws IOException, XMLParserException, InvalidConfigurationException, SQLException, InterruptedException {

        parseCmdArgs(args);

        List<String> warnings = new ArrayList<String>();
        boolean overwrite = true;
        //指定 逆向工程配置文件
        InputStream stream = ClassLoader.getSystemResourceAsStream("generatorConfig.xml");

        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(stream);

        Context defaultContext = config.getContext(DEFAULT_CONTEXT);

        //mysql
        JDBCConnectionConfiguration jdbcConnectionConfiguration = defaultContext.getJdbcConnectionConfiguration();
        String mysqlHost = getParam(MysqlHost, "localhost");
        String mysqlPort = getParam(MysqlPort, "3306");
        String mysqlDb = getParam(MysqlDB);
        String mysqlURL = "jdbc:mysql://" + mysqlHost + ":" + mysqlPort + "/" + mysqlDb + "?useUnicode=true&useSSL=false";
        jdbcConnectionConfiguration.setConnectionURL(mysqlURL);
        jdbcConnectionConfiguration.setUserId(getParam(MysqlUser, "root"));
        jdbcConnectionConfiguration.setPassword(getParam(MysqlPass));
//defaultContext.setJdbcConnectionConfiguration(jdbcConnectionConfiguration);

        //target
        JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = defaultContext.getJavaModelGeneratorConfiguration();
        javaModelGeneratorConfiguration.setTargetPackage(PKG_PREFIX + getParam(targetModule));
        String targetProject = getParam(targetDir, getRunTimePath());
        System.out.println(targetProject);
        javaModelGeneratorConfiguration.setTargetProject(targetProject);
//defaultContext.setJavaModelGeneratorConfiguration(javaModelGeneratorConfiguration);


        List<String> tables = getParamList(TABLES_KEY);

        List<TableConfiguration> tcs = defaultContext.getTableConfigurations();
        while (tcs.size() > 0) {
{'fraction_non_alphanumeric': 0.0959902794653706, 'fraction_numerical': 0.003037667071688943, 'mean_word_length': 4.628205128205129, 'pattern_counts': {'":': 2, '<': 16, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6270277', 'n_tokens_mistral': 1805, 'n_tokens_neox': 1776, 'n_words': 365}