1 8 9 package com.sleepycat.persist.model; 10 11 import java.io.File ; 12 import java.io.IOException ; 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.apache.tools.ant.BuildException; 17 import org.apache.tools.ant.DirectoryScanner; 18 import org.apache.tools.ant.Task; 19 import org.apache.tools.ant.types.FileSet; 20 21 50 public class ClassEnhancerTask extends Task { 51 52 private List <FileSet> fileSets = new ArrayList <FileSet>(); 53 private boolean verbose; 54 55 public void execute() throws BuildException { 56 if (fileSets.size() == 0) { 57 throw new BuildException("At least one fileset must be specified"); 58 } 59 try { 60 int nFiles = 0; 61 ClassEnhancer enhancer = new ClassEnhancer(); 62 enhancer.setVerbose(verbose); 63 for (FileSet fileSet : fileSets) { 64 DirectoryScanner scanner = 65 fileSet.getDirectoryScanner(getProject()); 66 String [] fileNames = scanner.getIncludedFiles(); 67 for (String fileName : fileNames) { 68 File file = new File (scanner.getBasedir(), fileName); 69 try { 70 nFiles += enhancer.enhanceFile(file); 71 } catch (IOException e) { 72 throw new BuildException(e); 73 } 74 } 75 } 76 if (nFiles > 0) { 77 System.out.println("Enhanced: " + nFiles + " files"); 78 } 79 } catch (RuntimeException e) { 80 e.printStackTrace(); 81 throw e; 82 } 83 } 84 85 public void addConfiguredFileset(FileSet files) { 86 fileSets.add(files); 87 } 88 89 public void setVerbose(boolean verbose) { 90 this.verbose = verbose; 91 } 92 } 93 | Popular Tags |