source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.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: 2.5 KB
Line 
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
29package org.apache.tools.ant.taskdefs.optional.unix;
30
31import org.apache.tools.ant.BuildException;
32
33/**
34 * Chgrp equivalent for unix-like environments.
35 *
36 *
37 * @since Ant 1.6
38 *
39 * @ant.task category="filesystem"
40 */
41public class Chgrp extends AbstractAccessTask {
42
43 private boolean haveGroup = false;
44
45 /**
46 * Chgrp task for setting unix group of a file.
47 */
48 public Chgrp() {
49 super.setExecutable("chgrp");
50 }
51
52 /**
53 * Set the group atribute.
54 *
55 * @param group The new group for the file(s) or directory(ies)
56 */
57 public void setGroup(String group) {
58 createArg().setValue(group);
59 haveGroup = true;
60 }
61
62 /**
63 * Ensure that all the required arguments and other conditions have
64 * been set.
65 */
66 protected void checkConfiguration() {
67 if (!haveGroup) {
68 throw new BuildException("Required attribute group not set in "
69 + "chgrp", getLocation());
70 }
71 super.checkConfiguration();
72 }
73
74 /**
75 * We don't want to expose the executable atribute, so overide it.
76 *
77 * @param e User supplied executable that we won't accept.
78 */
79 public void setExecutable(String e) {
80 throw new BuildException(getTaskType()
81 + " doesn\'t support the executable"
82 + " attribute", getLocation());
83 }
84}
Note: See TracBrowser for help on using the repository browser.