|
4 | 4 | import br.com.generator.core.GeneratorOptions;
|
5 | 5 | import br.com.templates_java.ComposeTemplate;
|
6 | 6 | import br.com.templates_java.config.jms_aws_sqs.*;
|
| 7 | +import br.com.templates_java.config.openj9.OpenJ9DockerfileGenerator; |
| 8 | +import br.com.templates_java.config.openj9.OpenJ9MavenPluginGenerator; |
7 | 9 | import joptsimple.OptionSet;
|
8 | 10 | import joptsimple.OptionSpec;
|
9 | 11 | import org.springframework.boot.cli.command.options.OptionHandler;
|
10 | 12 | import org.springframework.boot.cli.command.status.ExitStatus;
|
11 | 13 |
|
12 | 14 | import java.io.IOException;
|
13 | 15 | import java.net.URISyntaxException;
|
14 |
| -import java.util.Collections; |
15 | 16 | import java.util.HashMap;
|
16 | 17 | import java.util.List;
|
| 18 | +import java.util.Map; |
17 | 19 |
|
18 | 20 | import static java.util.Arrays.asList;
|
19 | 21 |
|
20 | 22 | public class TemplateHandler extends OptionHandler {
|
21 | 23 |
|
22 |
| - private List<String> templates = Collections.singletonList("jms-aws-sqs"); |
| 24 | + private List<String> templates = asList("jms-aws-sqs", "openj9"); |
23 | 25 |
|
24 | 26 | private OptionSpec<String> template;
|
25 | 27 | private OptionSpec<Void> listTemplates;
|
@@ -55,6 +57,30 @@ private ExitStatus executeTemplate(String template) {
|
55 | 57 | if (template.equals("jms-aws-sqs")) {
|
56 | 58 | return generateJmsAwsSQS();
|
57 | 59 | }
|
| 60 | + if (template.equals("openj9")) { |
| 61 | + return generateOpenJ9(); |
| 62 | + } |
| 63 | + return ExitStatus.OK; |
| 64 | + } |
| 65 | + |
| 66 | + private ExitStatus generateOpenJ9() { |
| 67 | + try { |
| 68 | + GeneratorOptions generatorOptions = new GeneratorOptions(); |
| 69 | + generatorOptions.setDestination(scaffoldInfo.getUserDir().concat("/deploy")); |
| 70 | + |
| 71 | + GeneratorOptions pomOptions = new GeneratorOptions(); |
| 72 | + pomOptions.setTemplatePath(scaffoldInfo.getPomPath()); |
| 73 | + pomOptions.setDestination(scaffoldInfo.getPomDest()); |
| 74 | + |
| 75 | + Map<String, String> keyValue = new HashMap<>(); |
| 76 | + keyValue.put("${main_class}", scaffoldInfo.getPathMainClass()); |
| 77 | + pomOptions.setPluginValues(keyValue); |
| 78 | + |
| 79 | + ComposeTemplate.runAll(scaffoldInfo.getPathPackage(), asList(new OpenJ9DockerfileGenerator(generatorOptions), new OpenJ9MavenPluginGenerator(pomOptions))); |
| 80 | + } catch (Exception e) { |
| 81 | + System.out.println("ERROR: ".concat(e.getMessage())); |
| 82 | + return ExitStatus.ERROR; |
| 83 | + } |
58 | 84 | return ExitStatus.OK;
|
59 | 85 | }
|
60 | 86 |
|
@@ -100,6 +126,7 @@ private boolean templateNotExists(String template) {
|
100 | 126 | private void output() {
|
101 | 127 | System.out.println("Templates available");
|
102 | 128 | System.out.println("* jms-aws-sqs");
|
| 129 | + System.out.println("* openj9"); |
103 | 130 | }
|
104 | 131 |
|
105 | 132 | }
|
0 commit comments