1 package com.kirkk.analyzer.textui; 2 3 import java.io.File ; 4 5 import org.apache.tools.ant.BuildException; 6 import org.apache.tools.ant.Task; 7 8 12 public class JarAnalyzerTask extends Task 13 { 14 private File srcdir; 15 private File destfile; 16 private String packageFilter; 17 private String jarFilter; 18 private String summaryclass; 19 20 21 public void setJarFilter(String jarFilter) { 22 this.jarFilter = jarFilter; 23 } 24 25 public void setPackageFilter(String packageFilter) { 26 this.packageFilter = packageFilter; 27 } 28 29 public void setSrcdir(File srcdir) 30 { 31 this.srcdir = srcdir; 32 } 33 34 public void setDestfile(File destfile) 35 { 36 this.destfile = destfile; 37 } 38 39 public void setSummaryclass(String summaryclass) 40 { 41 this.summaryclass = summaryclass; 42 } 43 44 public void execute() throws BuildException 45 { 46 validateAttributes(); 47 try 48 { 49 Class clazz = Class.forName(summaryclass); 50 Summary summary = (Summary)clazz.newInstance(); 51 summary.createSummary(srcdir, destfile, packageFilter, jarFilter); 52 log(destfile + " successfully created"); 53 } 54 catch(Exception exc) 55 { 56 throw new BuildException(exc); 57 } 58 } 59 60 private void validateAttributes() 61 { 62 if(null == srcdir) 63 { 64 throw new BuildException("Missing srcdir"); 65 } 66 if(null == destfile) 67 { 68 throw new BuildException("Missing destfile"); 69 } 70 if(!(srcdir.exists() && srcdir.isDirectory())) 71 { 72 throw new BuildException("srcdir must be a valid directory"); 73 } 74 if(destfile.isDirectory()) 75 { 76 throw new BuildException("srcdir must be a file"); 77 } 78 if(null == summaryclass) 79 { 80 throw new BuildException("Missing summaryclass"); 81 } 82 } 83 } 84 | Popular Tags |