public void generateSwift(ExecutionResult result) throws Exception { this.validateModel(result); if (!result.isOk()) { return; } this.getIo().deleteDirectory(this.getOutputDirectory()); result.append("-> Generating Swift classes..."); try { SwiftGenerator generator = new SwiftGenerator(); generator.generateAll(this.getProject(), this.getOutputDirectory()); result.append("-> *** Code generation OK ***"); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
public static void main(final String... args) throws Exception { final SwiftGeneratorConfig config = SwiftGeneratorConfig.builder() .inputBase(Resources.getResource(TestSwiftGenerator.class, "/basic/").toURI()) .outputFolder(new File(args.length == 0 ? OUTPUT_FOLDER : args[0])) .generateIncludedCode(true) .codeFlavor("java-immutable") .addTweak(SwiftGeneratorTweak.ADD_CLOSEABLE_INTERFACE) .addTweak(SwiftGeneratorTweak.EXTEND_RUNTIME_EXCEPTION) .addTweak(SwiftGeneratorTweak.ADD_THRIFT_EXCEPTION) .addTweak(SwiftGeneratorTweak.USE_PLAIN_JAVA_NAMESPACE) .build(); final SwiftGenerator generator = new SwiftGenerator(config); generator.parse( Lists.newArrayList( Resources.getResource(TestSwiftGenerator.class, "/basic/hive/metastore.thrift").toURI(), Resources.getResource(TestSwiftGenerator.class, "/basic/Maestro.thrift").toURI())); }