1 17 18 package org.apache.tools.ant.taskdefs.optional.sitraka; 19 20 import java.io.File ; 21 import org.apache.tools.ant.Task; 22 import org.apache.tools.ant.taskdefs.condition.Os; 23 import org.apache.tools.ant.util.FileUtils; 24 25 31 public abstract class CovBase extends Task { 32 private File home; 33 private static FileUtils fu = FileUtils.newFileUtils(); 34 private boolean isJProbe4 = false; 35 private static boolean isDos = Os.isFamily("dos"); 36 37 40 public void setHome(File value) { 41 this.home = value; 42 } 43 44 protected File getHome() { 45 return home; 46 } 47 48 protected File findCoverageJar() { 49 File loc = null; 50 if (isJProbe4) { 51 loc = fu.resolveFile(home, "lib/coverage.jar"); 52 } else { 53 loc = fu.resolveFile(home, "coverage/coverage.jar"); 54 if (!loc.canRead()) { 55 File newLoc = fu.resolveFile(home, "lib/coverage.jar"); 56 if (newLoc.canRead()) { 57 isJProbe4 = true; 58 loc = newLoc; 59 } 60 } 61 } 62 63 return loc; 64 } 65 66 protected String findExecutable(String relativePath) { 67 if (isDos) { 68 relativePath += ".exe"; 69 } 70 71 File loc = null; 72 if (isJProbe4) { 73 loc = fu.resolveFile(home, "bin/" + relativePath); 74 } else { 75 loc = fu.resolveFile(home, relativePath); 76 if (!loc.canRead()) { 77 File newLoc = fu.resolveFile(home, "bin/" + relativePath); 78 if (newLoc.canRead()) { 79 isJProbe4 = true; 80 loc = newLoc; 81 } 82 } 83 } 84 return loc.getAbsolutePath(); 85 } 86 87 protected File createTempFile(String prefix) { 88 return fu.createTempFile(prefix, ".tmp", null); 89 } 90 91 protected String getParamFileArgument() { 92 return "-" + (!isJProbe4 ? "jp_" : "") + "paramfile="; 93 } 94 95 98 protected boolean isJProbe4Plus() { 99 return isJProbe4; 100 } 101 } 102 | Popular Tags |