@Test public void springBootReadme() throws GeneratorException, IOException { InfoGenerator infoGenerator = getGeneratorForSpringBoot(); infoGenerator.generate(); File readme = Arrays.stream(Objects.requireNonNull(projectFolder.getRoot().listFiles())) .filter(f -> f.getName().equals("readme.txt")).findFirst().orElse(null); assertNotNull(readme); String readmeAsString = FileUtils.readFileToString(readme); assertTrue(readmeAsString.contains("mvn spring-boot:run -P env-dev")); assertTrue(readmeAsString.contains("java -jar artefactId-server\\target\\artefactId-server-1.0.0.war")); }
public void generate() throws GeneratorException { Configuration freeMarkerConfiguration = new Configuration(); freeMarkerConfiguration.setClassForTemplateLoading(InfoGenerator.class, "/templates"); freeMarkerConfiguration.setDefaultEncoding("UTF-8"); Template template; try { template = freeMarkerConfiguration.getTemplate("readme.ftl"); } catch (IOException e) { throw new GeneratorException("Unable to get >>readme.ftl<< -> exception: " + e.getMessage()); } Map<String, Object> templateData = new HashMap<>(); templateData.put("serverImplementation", this.naluGeneraterParms.getServerImplementation() .name()); templateData.put("artefactId", this.naluGeneraterParms.getArtefactId()); try (StringWriter out = new StringWriter()) { template.process(templateData, out); Files.write(Paths.get(this.projectFolder + File.separator + "readme.txt"), out.toString() .getBytes()); out.flush(); } catch (IOException | TemplateException e) { throw new GeneratorException("Unable to write generated file: >>" + this.projectFolder + File.separator + "readme.txt" + "<< -> exception: " + e.getMessage()); } }
InfoGenerator { public void generate() throws GeneratorException { Configuration freeMarkerConfiguration = new Configuration(); freeMarkerConfiguration.setClassForTemplateLoading(InfoGenerator.class, "/templates"); freeMarkerConfiguration.setDefaultEncoding("UTF-8"); Template template; try { template = freeMarkerConfiguration.getTemplate("readme.ftl"); } catch (IOException e) { throw new GeneratorException("Unable to get >>readme.ftl<< -> exception: " + e.getMessage()); } Map<String, Object> templateData = new HashMap<>(); templateData.put("serverImplementation", this.naluGeneraterParms.getServerImplementation() .name()); templateData.put("artefactId", this.naluGeneraterParms.getArtefactId()); try (StringWriter out = new StringWriter()) { template.process(templateData, out); Files.write(Paths.get(this.projectFolder + File.separator + "readme.txt"), out.toString() .getBytes()); out.flush(); } catch (IOException | TemplateException e) { throw new GeneratorException("Unable to write generated file: >>" + this.projectFolder + File.separator + "readme.txt" + "<< -> exception: " + e.getMessage()); } } }
InfoGenerator { public void generate() throws GeneratorException { Configuration freeMarkerConfiguration = new Configuration(); freeMarkerConfiguration.setClassForTemplateLoading(InfoGenerator.class, "/templates"); freeMarkerConfiguration.setDefaultEncoding("UTF-8"); Template template; try { template = freeMarkerConfiguration.getTemplate("readme.ftl"); } catch (IOException e) { throw new GeneratorException("Unable to get >>readme.ftl<< -> exception: " + e.getMessage()); } Map<String, Object> templateData = new HashMap<>(); templateData.put("serverImplementation", this.naluGeneraterParms.getServerImplementation() .name()); templateData.put("artefactId", this.naluGeneraterParms.getArtefactId()); try (StringWriter out = new StringWriter()) { template.process(templateData, out); Files.write(Paths.get(this.projectFolder + File.separator + "readme.txt"), out.toString() .getBytes()); out.flush(); } catch (IOException | TemplateException e) { throw new GeneratorException("Unable to write generated file: >>" + this.projectFolder + File.separator + "readme.txt" + "<< -> exception: " + e.getMessage()); } } private  InfoGenerator(Builder builder); }
InfoGenerator { public void generate() throws GeneratorException { Configuration freeMarkerConfiguration = new Configuration(); freeMarkerConfiguration.setClassForTemplateLoading(InfoGenerator.class, "/templates"); freeMarkerConfiguration.setDefaultEncoding("UTF-8"); Template template; try { template = freeMarkerConfiguration.getTemplate("readme.ftl"); } catch (IOException e) { throw new GeneratorException("Unable to get >>readme.ftl<< -> exception: " + e.getMessage()); } Map<String, Object> templateData = new HashMap<>(); templateData.put("serverImplementation", this.naluGeneraterParms.getServerImplementation() .name()); templateData.put("artefactId", this.naluGeneraterParms.getArtefactId()); try (StringWriter out = new StringWriter()) { template.process(templateData, out); Files.write(Paths.get(this.projectFolder + File.separator + "readme.txt"), out.toString() .getBytes()); out.flush(); } catch (IOException | TemplateException e) { throw new GeneratorException("Unable to write generated file: >>" + this.projectFolder + File.separator + "readme.txt" + "<< -> exception: " + e.getMessage()); } } private  InfoGenerator(Builder builder); static Builder builder(); void generate(); }
InfoGenerator { public void generate() throws GeneratorException { Configuration freeMarkerConfiguration = new Configuration(); freeMarkerConfiguration.setClassForTemplateLoading(InfoGenerator.class, "/templates"); freeMarkerConfiguration.setDefaultEncoding("UTF-8"); Template template; try { template = freeMarkerConfiguration.getTemplate("readme.ftl"); } catch (IOException e) { throw new GeneratorException("Unable to get >>readme.ftl<< -> exception: " + e.getMessage()); } Map<String, Object> templateData = new HashMap<>(); templateData.put("serverImplementation", this.naluGeneraterParms.getServerImplementation() .name()); templateData.put("artefactId", this.naluGeneraterParms.getArtefactId()); try (StringWriter out = new StringWriter()) { template.process(templateData, out); Files.write(Paths.get(this.projectFolder + File.separator + "readme.txt"), out.toString() .getBytes()); out.flush(); } catch (IOException | TemplateException e) { throw new GeneratorException("Unable to write generated file: >>" + this.projectFolder + File.separator + "readme.txt" + "<< -> exception: " + e.getMessage()); } } private  InfoGenerator(Builder builder); static Builder builder(); void generate();  }