1 7 package com.inversoft.savant.ant.taskdefs; 8 9 10 import java.io.File ; 11 import java.io.FileNotFoundException ; 12 import java.io.FileReader ; 13 import java.io.IOException ; 14 15 import org.apache.tools.ant.BuildException; 16 import org.apache.tools.ant.Task; 17 18 19 28 public class CVSVersionTask extends Task { 29 30 private String property; 31 32 33 38 public void setProperty(String property) { 39 this.property = property; 40 } 41 42 43 48 public void execute() throws BuildException { 49 File file = new File ("CVS/Tag"); 50 if (file.exists() && file.isFile()) { 51 52 StringBuffer buf = new StringBuffer (16); 54 try { 55 FileReader reader = new FileReader (file); 56 int ch = reader.read(); 57 while (ch != -1) { 58 buf.append((char) ch); 59 ch = reader.read(); 60 } 61 } catch (FileNotFoundException e) { 62 throw new BuildException(e); 63 } catch (IOException ioe) { 64 throw new BuildException(ioe); 65 } 66 67 String tag = buf.toString().trim(); 68 getProject().setProperty(property, tag.substring(1)); 69 } else { 70 getProject().setProperty(property, "0.0.0"); 71 } 72 } 73 } 74 | Popular Tags |