private void buildXmlPropertiesFile() { System.out.println( "\nBuilding and checking your pipeline properties file -> " + truncPipePropFile); StringBuilder toPrint = new StringBuilder(); // walk through the prop file String[] prop = IO.loadFileIntoStringArray(truncPipePropFile); Pattern val = Pattern.compile("(<entry key.+>)([D|A|B].*)</entry>"); boolean missingFile = false; for (String s : prop) { // does it match a file needing prepending? Data/, Apps/, Bed/ Matcher mat = val.matcher(s); if (mat.matches()) { File test = new File(referenceDir, mat.group(2)); if (test.exists()) { System.out.println("Found\t" + test); toPrint.append(mat.group(1)); toPrint.append(test.toString()); toPrint.append("</entry>"); } else { System.out.println("Misssing\t" + test); missingFile = true; } } // threads? else if (s.contains("threads")) toPrint.append("<entry key=\"threads\">" + threads + "</entry>"); // nope just save it and add a line return else toPrint.append(s); toPrint.append("\n"); } // anything missing? if so exit if (missingFile) Misc.printErrAndExit( "\nFailed to find all of the files in your properties file, see above.\n"); // OK, write it out completePipelinePropFile = new File(outputDirectory, "pipelineProperties.xml"); if (IO.writeString(toPrint.toString(), completePipelinePropFile) == false) Misc.printErrAndExit("Problem writing -> " + truncPipePropFile); }
private void executePipelineJob() { String[] cmd = null; try { // write out tempTemplate File template = new File(outputDirectory, "pipelineTemplate.xml"); if (IO.writeString(xmlTemplate, template) == false) Misc.printErrAndExit("Problem writing -> " + template); // build and execute cmd cmd = new String[] { "java", "-jar", "-Xmx2G", pJar.getCanonicalPath(), "-props", completePipelinePropFile.getCanonicalPath(), template.getCanonicalPath() }; String stringCmd = Misc.stringArrayToString(cmd, " "); System.out.println("\nExecuting:\n" + stringCmd); System.out.println("\nPipelineOutput:"); String[] out = IO.executeViaProcessBuilder(cmd, true); // check output for possible errors for (String line : out) { String lcLine = line.toLowerCase(); // watch out for cases where error is mentioned in a warning output line. if (lcLine.contains("error") && lcLine.startsWith("warning") == false) Misc.printErrAndExit( "\n\nERROR found in Pipeline.jar output, see above. Aborting!\n" + line); } } catch (Exception e) { e.printStackTrace(); Misc.printErrAndExit("ERROR: executing " + Misc.stringArrayToString(cmd, " ")); } }