@Override public void buildStarted(BuildEvent be) { TraceManager.BeginTrace(); if (autoTrace) TraceManager.GetTrace() .beginEntry( String.format("Start build '%'.", be.getProject().getName()), SeverityType.INFO); }
@Override void preModule(BuildEvent event) throws InterruptedException, IOException, AbortException { File baseDir = event.getProject().getBaseDir(); // TODO: find the module that contains this path? // ModuleName name = new ModuleName(event.getProject().getBaseDir()); // IvyBuildProxy2 proxy = proxies.get(name); // listener.getLogger().flush(); // make sure the data until here are all written // proxy.start(); // for (IvyReporter r : reporters.get(name)) // if(!r.preBuild(proxy,event,listener)) // throw new AbortException(r+" failed"); }
/** * Fired when the build finishes, this adds the time taken and any error stacktrace to the build * element and writes the document to disk. * * @param event An event with any relevant extra information. Will not be <code>null</code>. */ public void buildFinished(BuildEvent event) { long totalTime = System.currentTimeMillis() - buildElement.startTime; // buildElement.element.setAttribute(TIME_ATTR, // DefaultLogger.formatTime(totalTime)); System.out.println("Build finished in cruise control HeliumCCLogger"); if (event.getException() != null) { System.out.println("Build finished exception occured in cruise control HeliumCCLogger"); System.out.println("Build finished exception is:-----" + event.getException().toString()); buildElement.element.setAttribute(ERROR_ATTR, event.getException().toString()); // print the stacktrace in the build file it is always useful... // better have too much info than not enough. Throwable t = event.getException(); Text errText = doc.createCDATASection(StringUtils.getStackTrace(t)); Element stacktrace = doc.createElement(STACKTRACE_TAG); stacktrace.appendChild(errText); buildElement.element.appendChild(stacktrace); } String outFilename = event.getProject().getProperty("HeliumCCLogger.file"); System.out.println("Build finished writing to log file1" + outFilename); if (outFilename == null) { outFilename = "log.xml"; } System.out.println("Build finished writing to log file2"); String xslUri = event.getProject().getProperty("ant.HeliumCCLogger.stylesheet.uri"); if (xslUri == null) { xslUri = "log.xsl"; } System.out.println("Build finished writing to log file3"); Writer out = null; try { // specify output in UTF8 otherwise accented characters will blow // up everything System.out.println("Build finished writing to log file3"); OutputStream stream = outStream; if (stream == null) { stream = new FileOutputStream(outFilename); } out = new OutputStreamWriter(stream, "UTF8"); System.out.println("Build finished writing to log file4"); out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); if (xslUri.length() > 0) { out.write("<?xml-stylesheet type=\"text/xsl\" href=\"" + xslUri + "\"?>\n\n"); } System.out.println("Build finished writing to log file5"); (new DOMElementWriter()).write(buildElement.element, out, 0, "\t"); out.flush(); } catch (IOException exc) { System.out.println("Build finished writing to log file6"); throw new BuildException("Unable to write log file", exc); } finally { System.out.println("Build finished writing to log file7"); if (out != null) { try { out.close(); } catch (IOException e) { // ignore e = null; } } } buildElement = null; }