@Test public void minimum() throws Exception { File output = folder.newFolder("output"); File source = folder.newFile("example.dmdl"); List<String> arguments = new ArrayList<>(); Collections.addAll(arguments, "-output", output.getPath()); Collections.addAll(arguments, "-source", source.getPath()); Collections.addAll(arguments, "-package", "com.example.testing"); Configuration config = Main.configure(arguments.toArray(new String[arguments.size()])); assertThat(config.getSource(), is(source("example.dmdl"))); assertThat(config.getOutput(), is(target(output))); assertThat(config.getBasePackage().toNameString(), is("com.example.testing")); }
static Configuration configure(String[] args) throws ParseException { assert args != null; CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, args); String output = cmd.getOptionValue(OPT_OUTPUT.getOpt()); String packageName = cmd.getOptionValue(OPT_PACKAGE.getOpt()); Charset sourceEnc = parseCharset(cmd.getOptionValue(OPT_SOURCE_ENCODING.getOpt())); Charset targetEnc = parseCharset(cmd.getOptionValue(OPT_TARGET_ENCODING.getOpt())); String sourcePaths = cmd.getOptionValue(OPT_SOURCE_PATH.getOpt()); String plugin = cmd.getOptionValue(OPT_PLUGIN.getOpt()); File outputDirectory = new File(output); DmdlSourceRepository source = buildRepository(parseFileList(sourcePaths), sourceEnc); ClassLoader serviceLoader = buildPluginLoader(Main.class.getClassLoader(), parseFileList(plugin)); ModelFactory factory = Models.getModelFactory(); return new Configuration( factory, source, Models.toName(factory, packageName), new Filer(outputDirectory, targetEnc), serviceLoader, Locale.getDefault()); }
Main { static Configuration configure(String[] args) throws ParseException { assert args != null; CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, args); String output = cmd.getOptionValue(OPT_OUTPUT.getOpt()); String packageName = cmd.getOptionValue(OPT_PACKAGE.getOpt()); Charset sourceEnc = parseCharset(cmd.getOptionValue(OPT_SOURCE_ENCODING.getOpt())); Charset targetEnc = parseCharset(cmd.getOptionValue(OPT_TARGET_ENCODING.getOpt())); String sourcePaths = cmd.getOptionValue(OPT_SOURCE_PATH.getOpt()); String plugin = cmd.getOptionValue(OPT_PLUGIN.getOpt()); File outputDirectory = new File(output); DmdlSourceRepository source = buildRepository(parseFileList(sourcePaths), sourceEnc); ClassLoader serviceLoader = buildPluginLoader(Main.class.getClassLoader(), parseFileList(plugin)); ModelFactory factory = Models.getModelFactory(); return new Configuration( factory, source, Models.toName(factory, packageName), new Filer(outputDirectory, targetEnc), serviceLoader, Locale.getDefault()); } }
Main { static Configuration configure(String[] args) throws ParseException { assert args != null; CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, args); String output = cmd.getOptionValue(OPT_OUTPUT.getOpt()); String packageName = cmd.getOptionValue(OPT_PACKAGE.getOpt()); Charset sourceEnc = parseCharset(cmd.getOptionValue(OPT_SOURCE_ENCODING.getOpt())); Charset targetEnc = parseCharset(cmd.getOptionValue(OPT_TARGET_ENCODING.getOpt())); String sourcePaths = cmd.getOptionValue(OPT_SOURCE_PATH.getOpt()); String plugin = cmd.getOptionValue(OPT_PLUGIN.getOpt()); File outputDirectory = new File(output); DmdlSourceRepository source = buildRepository(parseFileList(sourcePaths), sourceEnc); ClassLoader serviceLoader = buildPluginLoader(Main.class.getClassLoader(), parseFileList(plugin)); ModelFactory factory = Models.getModelFactory(); return new Configuration( factory, source, Models.toName(factory, packageName), new Filer(outputDirectory, targetEnc), serviceLoader, Locale.getDefault()); } private  Main(); }
Main { static Configuration configure(String[] args) throws ParseException { assert args != null; CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, args); String output = cmd.getOptionValue(OPT_OUTPUT.getOpt()); String packageName = cmd.getOptionValue(OPT_PACKAGE.getOpt()); Charset sourceEnc = parseCharset(cmd.getOptionValue(OPT_SOURCE_ENCODING.getOpt())); Charset targetEnc = parseCharset(cmd.getOptionValue(OPT_TARGET_ENCODING.getOpt())); String sourcePaths = cmd.getOptionValue(OPT_SOURCE_PATH.getOpt()); String plugin = cmd.getOptionValue(OPT_PLUGIN.getOpt()); File outputDirectory = new File(output); DmdlSourceRepository source = buildRepository(parseFileList(sourcePaths), sourceEnc); ClassLoader serviceLoader = buildPluginLoader(Main.class.getClassLoader(), parseFileList(plugin)); ModelFactory factory = Models.getModelFactory(); return new Configuration( factory, source, Models.toName(factory, packageName), new Filer(outputDirectory, targetEnc), serviceLoader, Locale.getDefault()); } private  Main(); static void main(String... args); }
Main { static Configuration configure(String[] args) throws ParseException { assert args != null; CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, args); String output = cmd.getOptionValue(OPT_OUTPUT.getOpt()); String packageName = cmd.getOptionValue(OPT_PACKAGE.getOpt()); Charset sourceEnc = parseCharset(cmd.getOptionValue(OPT_SOURCE_ENCODING.getOpt())); Charset targetEnc = parseCharset(cmd.getOptionValue(OPT_TARGET_ENCODING.getOpt())); String sourcePaths = cmd.getOptionValue(OPT_SOURCE_PATH.getOpt()); String plugin = cmd.getOptionValue(OPT_PLUGIN.getOpt()); File outputDirectory = new File(output); DmdlSourceRepository source = buildRepository(parseFileList(sourcePaths), sourceEnc); ClassLoader serviceLoader = buildPluginLoader(Main.class.getClassLoader(), parseFileList(plugin)); ModelFactory factory = Models.getModelFactory(); return new Configuration( factory, source, Models.toName(factory, packageName), new Filer(outputDirectory, targetEnc), serviceLoader, Locale.getDefault()); } private  Main(); static void main(String... args);  }