1 17 package org.apache.tools.ant.taskdefs.optional.ide; 18 19 20 import java.util.Enumeration ; 21 import java.util.Vector ; 22 import org.apache.tools.ant.BuildException; 23 import org.apache.tools.ant.DirectoryScanner; 24 import org.apache.tools.ant.types.FileSet; 25 26 90 public class VAJImport extends VAJTask { 91 protected Vector filesets = new Vector (); 92 protected boolean importSources = true; 93 protected boolean importResources = true; 94 protected boolean importClasses = false; 95 protected String importProject = null; 96 protected boolean useDefaultExcludes = true; 97 98 99 113 private static class LocalDirectoryScanner extends DirectoryScanner { 114 public String [] getIncludes() { return includes; } 115 public String [] getExcludes() { return excludes; } 116 } 117 118 121 public void setProject(String projectName) { 122 this.importProject = projectName; 123 } 124 125 128 public void addFileset(FileSet set) { 129 filesets.addElement(set); 130 } 131 132 135 public void setImportClasses(boolean importClasses) { 136 this.importClasses = importClasses; 137 } 138 139 143 public void setImportResources(boolean importResources) { 144 this.importResources = importResources; 145 } 146 147 150 public void setImportSources(boolean importSources) { 151 this.importSources = importSources; 152 } 153 154 161 public void setDefaultexcludes(boolean useDefaultExcludes) { 162 this.useDefaultExcludes = useDefaultExcludes; 163 } 164 165 168 public void execute() throws BuildException { 169 if (filesets.size() == 0) { 170 throw new BuildException("At least one fileset is required!"); 171 } 172 173 if (importProject == null || "".equals(importProject)) { 174 throw new BuildException("The VisualAge for Java Project name is required!"); 175 } 176 177 try { 178 for (Enumeration e = filesets.elements(); e.hasMoreElements();) { 179 importFileset((FileSet) e.nextElement()); 180 } 181 } catch (BuildException ex) { 182 if (haltOnError) { 183 throw ex; 184 } else { 185 log(ex.toString()); 186 } 187 } 188 } 189 190 194 protected void importFileset(FileSet fileset) { 195 LocalDirectoryScanner ds = new LocalDirectoryScanner(); 196 fileset.setupDirectoryScanner(ds, this.getProject()); 197 ds.scan(); 198 if (ds.getIncludedFiles().length == 0) { 199 return; 200 } 201 202 String [] includes = ds.getIncludes(); 203 String [] excludes = ds.getExcludes(); 204 205 getUtil().importFiles(importProject, ds.getBasedir(), 206 includes, excludes, 207 importClasses, importResources, importSources, 208 useDefaultExcludes); 209 } 210 } 211 | Popular Tags |