1 | /*
|
---|
2 | * Copyright 2002-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 |
|
---|
18 | /*
|
---|
19 | * Since the initial version of this file was deveolped on the clock on
|
---|
20 | * an NSF grant I should say the following boilerplate:
|
---|
21 | *
|
---|
22 | * This material is based upon work supported by the National Science
|
---|
23 | * Foundaton under Grant No. EIA-0196404. Any opinions, findings, and
|
---|
24 | * conclusions or recommendations expressed in this material are those
|
---|
25 | * of the author and do not necessarily reflect the views of the
|
---|
26 | * National Science Foundation.
|
---|
27 | */
|
---|
28 |
|
---|
29 | package org.apache.tools.ant.taskdefs.optional.unix;
|
---|
30 |
|
---|
31 | import java.io.File;
|
---|
32 |
|
---|
33 | import org.apache.tools.ant.BuildException;
|
---|
34 | import org.apache.tools.ant.taskdefs.condition.Os;
|
---|
35 | import org.apache.tools.ant.types.Commandline;
|
---|
36 | import org.apache.tools.ant.types.FileSet;
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * @since Ant 1.6
|
---|
40 | *
|
---|
41 | * @ant.task category="filesystem"
|
---|
42 | */
|
---|
43 |
|
---|
44 | public abstract class AbstractAccessTask
|
---|
45 | extends org.apache.tools.ant.taskdefs.ExecuteOn {
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Chmod task for setting file and directory permissions.
|
---|
49 | */
|
---|
50 | public AbstractAccessTask() {
|
---|
51 | super.setParallel(true);
|
---|
52 | super.setSkipEmptyFilesets(true);
|
---|
53 | }
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Set the file which should have its access attributes modified.
|
---|
57 | */
|
---|
58 | public void setFile(File src) {
|
---|
59 | FileSet fs = new FileSet();
|
---|
60 | fs.setFile(src);
|
---|
61 | addFileset(fs);
|
---|
62 | }
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Prevent the user from specifying a different command.
|
---|
66 | *
|
---|
67 | * @ant.attribute ignore="true"
|
---|
68 | * @param cmdl A user supplied command line that we won't accept.
|
---|
69 | */
|
---|
70 | public void setCommand(Commandline cmdl) {
|
---|
71 | throw new BuildException(getTaskType()
|
---|
72 | + " doesn\'t support the command attribute",
|
---|
73 | getLocation());
|
---|
74 | }
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * Prevent the skipping of empty filesets
|
---|
78 | *
|
---|
79 | * @ant.attribute ignore="true"
|
---|
80 | * @param skip A user supplied boolean we won't accept.
|
---|
81 | */
|
---|
82 | public void setSkipEmptyFilesets(boolean skip) {
|
---|
83 | throw new BuildException(getTaskType() + " doesn\'t support the "
|
---|
84 | + "skipemptyfileset attribute",
|
---|
85 | getLocation());
|
---|
86 | }
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * Prevent the use of the addsourcefile atribute.
|
---|
90 | *
|
---|
91 | * @ant.attribute ignore="true"
|
---|
92 | * @param b A user supplied boolean we won't accept.
|
---|
93 | */
|
---|
94 | public void setAddsourcefile(boolean b) {
|
---|
95 | throw new BuildException(getTaskType()
|
---|
96 | + " doesn\'t support the addsourcefile attribute", getLocation());
|
---|
97 | }
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Automatically approve Unix OS's.
|
---|
101 | */
|
---|
102 | protected boolean isValidOs() {
|
---|
103 | return Os.isFamily("unix") && super.isValidOs();
|
---|
104 | }
|
---|
105 | }
|
---|