/** * Saves the pom.xml if its been changed * * @return true if the pom was modified * @throws IOException */ public boolean saveIfChanged() throws IOException { if (updated) { LOG.info("Updating " + pom); try { IOHelpers.writeFully(pom, doc.toXML()); } catch (Exception e) { throw new IOException("failed to save " + pom + ". " + e, e); } } return updated; }
/** * Saves the pom.xml if its been changed * * @return true if the pom was modified * @throws IOException */ public boolean saveIfChanged() throws IOException { if (updated) { LOG.info("Updating " + pom); try { IOHelpers.writeFully(pom, doc.toXML()); } catch (Exception e) { throw new IOException("failed to save " + pom + ". " + e, e); } } return updated; }
public static void savePrettyJson(File file, Object value) throws IOException { // lets use the node layout NpmJsonPrettyPrinter printer = new NpmJsonPrettyPrinter(); ObjectMapper objectMapper = createPrettyJsonObjectMapper(); objectMapper.setDefaultPrettyPrinter(printer); String json = objectMapper.writer().writeValueAsString(value); IOHelpers.writeFully(file, json + System.lineSeparator()); }
/** * Git tends to ignore empty directories so lets add a dummy file to empty folders to keep them in git */ public static void addDummyFileToEmptyFolders(File dir) { if (dir != null && dir.isDirectory()) { File[] children = dir.listFiles(); if (children == null || children.length == 0) { File dummyFile = new File(dir, ".gitkeep"); try { IOHelpers.writeFully(dummyFile, "This file is only here to avoid git removing empty folders\nOnce there are files in this folder feel free to delete this file!"); } catch (IOException e) { LOG.warn("Failed to write file " + dummyFile + ". " + e, e); } } else { for (File child : children) { if (child.isDirectory()) { addDummyFileToEmptyFolders(child); } } } } }
public static void savePrettyJson(File file, Object value) throws IOException { // lets use the node layout NpmJsonPrettyPrinter printer = new NpmJsonPrettyPrinter(); ObjectMapper objectMapper = createPrettyJsonObjectMapper(); objectMapper.setDefaultPrettyPrinter(printer); String json = objectMapper.writer().writeValueAsString(value); IOHelpers.writeFully(file, json + System.lineSeparator()); }
protected void copyFile(File src, File dest, Replacement replaceFn, boolean isSource) throws IOException { if (replaceFn != null && isSource) { String original = IOHelpers.readFully(src); String escapedContent = original; if (original.contains("${")) { String replaced = escapedContent.replaceAll(Pattern.quote("${"), "\\${D}{"); // add Velocity expression at the beginning of the result file. // Velocity is used by mvn archetype:generate escapedContent = "#set( $D = '$' )\n" + replaced; } if (original.contains("##")) { String replaced = escapedContent.replaceAll(Pattern.quote("##"), "\\${H}"); // add Velocity expression at the beginning of the result file. // Velocity is used by mvn archetype:generate escapedContent = "#set( $H = '##' )\n" + replaced; } // do additional replacement String text = replaceFn.replace(escapedContent); IOHelpers.writeFully(dest, text); } else { if (LOG.isDebugEnabled()) { LOG.warn("Not a source dir as the extension is {}", Files.getExtension(src.getName())); } Files.copy(src, dest); } }
LOG.warn("Could not find the url in the formula to update the sha256"); IOHelpers.writeFully(rb, updatedText);
" </build>\n" + "</project>"; IOHelpers.writeFully(new File(projectDir, "pom.xml"), pomXml); IOHelpers.writeFully(dummyJavaFile, dummyJavaClass); "}\n" + "return this;\n"; IOHelpers.writeFully(new File(getBaseDir(), "../releaseImages.groovy"), releaseImagesGroovy);
File logFile = LogHelpers.getLogFileName(session.getBaseDir(), name, container, restartCount); String log = kubernetesClient.pods().inNamespace(session.getNamespace()).withName(name).inContainer(container.getName()).getLog(); IOHelpers.writeFully(logFile, log);