1 7 package com.inversoft.savant.ant.types; 8 9 10 import java.io.File ; 11 12 import org.apache.tools.ant.BuildException; 13 import org.apache.tools.ant.taskdefs.Cvs; 14 import org.apache.tools.ant.types.DataType; 15 16 import com.inversoft.savant.Artifact; 17 import com.inversoft.savant.LocalCacheStore; 18 import com.inversoft.savant.Process; 19 import com.inversoft.savant.SavantException; 20 21 22 31 public class CVSProcess extends DataType implements Process { 32 33 private String cvsroot; 34 private boolean compression; 35 private int compressionlevel; 36 private String cvsrsh; 37 private File dest; 38 private String pack; 39 private String tag; 40 private String date; 41 private int port; 42 private File passfile; 43 44 45 49 public CVSProcess() { 50 } 51 52 53 public void setCvsroot(String cvsroot) { 54 this.cvsroot = cvsroot; 55 } 56 57 public void setCompression(boolean compression) { 58 this.compression = compression; 59 } 60 61 public void setCompressionlevel(int compressionlevel) { 62 this.compressionlevel = compressionlevel; 63 } 64 65 public void setCvsrsh(String cvsrsh) { 66 this.cvsrsh = cvsrsh; 67 } 68 69 public void setDest(File dest) { 70 this.dest = dest; 71 } 72 73 public void setPackage(String pack) { 74 this.pack = pack; 75 } 76 77 public void setTag(String tag) { 78 this.tag = tag; 79 } 80 81 public void setDate(String date) { 82 this.date = date; 83 } 84 85 public void setPort(int port) { 86 this.port = port; 87 } 88 89 public void setPassfile(File passfile) { 90 this.passfile = passfile; 91 } 92 93 104 public boolean resolveArtifactDependencies(Artifact artifact, 105 LocalCacheStore localCache) 106 throws SavantException { 107 File depsFile = executeCheckout(artifact.getArtifactDepsFile()); 108 if (depsFile.exists()) { 109 localCache.storeDeps(artifact, depsFile); 110 return true; 111 } 112 113 return false; 114 } 115 116 127 public File fetch(Artifact artifact, LocalCacheStore localCache) 128 throws SavantException { 129 File artifactFile = executeCheckout(artifact.getArtifactFile()); 130 if (artifactFile.exists()) { 131 artifactFile = localCache.store(artifact, artifactFile); 132 } else { 133 artifactFile = null; 134 } 135 136 return artifactFile; 137 } 138 139 protected File executeCheckout(String filePath) { 140 if (dest == null) { 142 dest = new File (System.getProperty("user.home") + File.separator + 143 ".savant_cvs_repository"); 144 } 145 146 Cvs cvs = (Cvs) getProject().createTask("cvs"); 147 cvs.setPackage(pack); 148 cvs.setCvsRoot(cvsroot); 149 cvs.setCvsRsh(cvsrsh); 150 cvs.setCompression(compression); 151 cvs.setCompressionLevel(compressionlevel); 152 cvs.setDest(dest); 153 cvs.setTag(tag); 154 cvs.setDate(date); 155 cvs.setPort(port); 156 cvs.setPassfile(passfile); 157 cvs.setReallyquiet(true); 158 159 String module = pack + File.separator + filePath; 161 cvs.setPackage(module); 162 cvs.perform(); 163 164 String file = pack + File.separator + filePath; 165 return new File (dest, file); 166 } 167 168 173 public void validate() throws BuildException { 174 if (pack == null) { 175 throw new BuildException("A package must be specified"); 176 } 177 } 178 } 179 | Popular Tags |