From: Whitlock, J. x. <Jer...@ad...> - 2004-08-25 19:19:53
|
CC-List, I have devised a way to give the user the capability to copy = the logfile to an external location for their specific needs. I used the = advice given to modify the AntBuilder.java file. Basically, the user will have = an attribute "antSaveLogLocation" in the <ant> element. If it's there and = it's not null or invalid, the user's ant log file will be copied to that location. Here is the code: =20 private String antSaveLogLocation =3D null; =20 /** * Set the location to which the ant log will be saved before=20 * Cruise Control merges the file into its log. * @param dir the absolute path to the directory where the=20 * ant log will be saved or relative path to where you started=20 * CruiseControl */ public void setAntSaveLogLocation(String dir) { antSaveLogLocation =3D dir; } =20 if (antSaveLogLocation !=3D null && = !antSaveLogLocation.trim().equals("")) { File antSaveLogDir =3D new File(antSaveLogLocation); File newAntLogFile =3D null; =20 try { antSaveLogDir.mkdirs(); =20 newAntLogFile =3D new File(antSaveLogLocation=20 + System.getProperty("file.separator") + tempFileName); =20 newAntLogFile.createNewFile(); =20 InputStream in =3D new FileInputStream(logFile); OutputStream out =3D new FileOutputStream(newAntLogFile); =20 // Transfer bytes from in to out byte[] buf =3D new byte[1024]; int len; while ((len =3D in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); } catch (SecurityException se) { LOG.fatal(antSaveLogDir, se); LOG.info("Unable to create the directory: " + antSaveLogLocation); } catch (IOException ioe) { LOG.fatal(newAntLogFile, ioe); LOG.info("Unable to create file: " + newAntLogFile); } } =20 The above if statement would be inserted here: =20 if (logFile.exists()) { //insert here logFile.delete(); } =20 The ant usage is as follows: =20 <schedule interval=3D"60"> <ant = buildfile=3D"D:\Develop\&posseprojectversion;\build_script\build.xml" target=3D"continuousintegration"=20 uselogger=3D"true" usedebug=3D"false" antWorkingDir=3D"D:\Develop\&posseprojectversion;\build_script"=20 = antSaveLogLocation=3D"&cchome;/work/reports/ant"> </ant> </schedule> =20 I haven't created a test case in the CC TestSuite but I have tested the scenarios I could think of. If this was to be put into CC, I could = write the tests out. Laters, Jeremy =20 -----Original Message----- From: Whitlock, Jeremy x66075=20 Sent: Wednesday, August 25, 2004 9:15 AM To: CruiseControl (E-mail) Subject: Ant's log file =20 CC-List, Ant has logging features letting you log to a specific file. = CC deletes this file behind the scenes taking away the ability of a = developer to use ant's log file for later use because it deletes the file without giving the user any capability to save off that file before deleting. = The developer doesn't even have the ability to toggle this "feature" on or = off. My question is should CC override ant in the way that it is currently = doing? For those needing to keep the ant log file it is possible to modify the AntBuilder.java to suite your needs but would it be in CC's best = interest to give the user the capability of turning on/off the deletion of the ant = log? (Possibly through a subelement of the <ant> element in config.xml or via attributes in the <ant> element.) My belief is that if CC doesn't create/maintain a resource, it shouldn't try to modify/delete that = resource under the covers. I'm not a CC developer and this could be an edge case = but can someone please give me some feedback on this? I would like to know where others stand on this or bring information to my attention to = support the way CC does this now. Thanks, Jeremy _ This message and any attachments are intended only for the use of the = addressee and may contain information that is privileged and confidential. If the = reader of the=20 message is not the intended recipient or an authorized representative of = the intended recipient, you are hereby notified that any dissemination of = this communication is strictly prohibited. If you have received this = communication in error, please notify us immediately by e-mail and delete the message and = any attachments from your system. |