source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 3.3 KB
Line 
1/*
2 * Copyright 2003-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant.taskdefs;
19
20import org.apache.tools.ant.Task;
21import org.apache.tools.ant.Project;
22import org.apache.tools.ant.BuildException;
23import org.apache.tools.ant.DirectoryScanner;
24
25/**
26 * Alters the default excludes for the <strong>entire</strong> build..
27 *
28 *
29 * @since Ant 1.6
30 *
31 * @ant.task category="utility"
32 */
33public class DefaultExcludes extends Task {
34 private String add = "";
35 private String remove = "";
36 private boolean defaultrequested = false;
37 private boolean echo = false;
38
39 // by default, messages are always displayed
40 private int logLevel = Project.MSG_WARN;
41
42 /**
43 * Does the work.
44 *
45 * @exception BuildException if something goes wrong with the build
46 */
47 public void execute() throws BuildException {
48 if (!defaultrequested && add.equals("") && remove.equals("") && !echo) {
49 throw new BuildException("<defaultexcludes> task must set "
50 + "at least one attribute (echo=\"false\""
51 + " doesn't count since that is the default");
52 }
53 if (defaultrequested) {
54 DirectoryScanner.resetDefaultExcludes();
55 }
56 if (!add.equals("")) {
57 DirectoryScanner.addDefaultExclude(add);
58 }
59 if (!remove.equals("")) {
60 DirectoryScanner.removeDefaultExclude(remove);
61 }
62 if (echo) {
63 StringBuffer message
64 = new StringBuffer("Current Default Excludes:\n");
65 String[] excludes = DirectoryScanner.getDefaultExcludes();
66 for (int i = 0; i < excludes.length; i++) {
67 message.append(" " + excludes[i] + "\n");
68 }
69 log(message.toString(), logLevel);
70 }
71 }
72
73 /**
74 * go back to standard default patterns
75 *
76 * @param def if true go back to default patterns
77 */
78 public void setDefault(boolean def) {
79 defaultrequested = def;
80 }
81 /**
82 * Pattern to add to the default excludes
83 *
84 * @param add Sets the value for the pattern to exclude.
85 */
86 public void setAdd(String add) {
87 this.add = add;
88 }
89
90 /**
91 * Pattern to remove from the default excludes.
92 *
93 * @param remove Sets the value for the pattern that
94 * should no longer be excluded.
95 */
96 public void setRemove(String remove) {
97 this.remove = remove;
98 }
99
100 /**
101 * If true, echo the default excludes.
102 *
103 * @param echo whether or not to echo the contents of
104 * the default excludes.
105 */
106 public void setEcho(boolean echo) {
107 this.echo = echo;
108 }
109
110
111}
Note: See TracBrowser for help on using the repository browser.