1 18 19 package org.apache.tools.ant.taskdefs; 20 21 import org.apache.tools.ant.Task; 22 import org.apache.tools.ant.Project; 23 import org.apache.tools.ant.BuildException; 24 import org.apache.tools.ant.DirectoryScanner; 25 import org.apache.tools.ant.util.StringUtils; 26 27 34 public class DefaultExcludes extends Task { 35 private String add = ""; 36 private String remove = ""; 37 private boolean defaultrequested = false; 38 private boolean echo = false; 39 40 private int logLevel = Project.MSG_WARN; 42 43 48 public void execute() throws BuildException { 49 if (!defaultrequested && add.equals("") && remove.equals("") && !echo) { 50 throw new BuildException("<defaultexcludes> task must set " 51 + "at least one attribute (echo=\"false\"" 52 + " doesn't count since that is the default"); 53 } 54 if (defaultrequested) { 55 DirectoryScanner.resetDefaultExcludes(); 56 } 57 if (!add.equals("")) { 58 DirectoryScanner.addDefaultExclude(add); 59 } 60 if (!remove.equals("")) { 61 DirectoryScanner.removeDefaultExclude(remove); 62 } 63 if (echo) { 64 StringBuffer message 65 = new StringBuffer ("Current Default Excludes:"); 66 message.append(StringUtils.LINE_SEP); 67 String [] excludes = DirectoryScanner.getDefaultExcludes(); 68 for (int i = 0; i < excludes.length; i++) { 69 message.append(" "); 70 message.append(excludes[i]); 71 message.append(StringUtils.LINE_SEP); 72 } 73 log(message.toString(), logLevel); 74 } 75 } 76 77 82 public void setDefault(boolean def) { 83 defaultrequested = def; 84 } 85 90 public void setAdd(String add) { 91 this.add = add; 92 } 93 94 100 public void setRemove(String remove) { 101 this.remove = remove; 102 } 103 104 110 public void setEcho(boolean echo) { 111 this.echo = echo; 112 } 113 114 115 } 116 | Popular Tags |