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