Browse Source

- Incorrectly overloads the setCommand method instead of overriding it.

- Minor code layout


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270648 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 23 years ago
parent
commit
05b398c9b6
1 changed files with 22 additions and 24 deletions
  1. +22
    -24
      src/main/org/apache/tools/ant/taskdefs/Chmod.java

+ 22
- 24
src/main/org/apache/tools/ant/taskdefs/Chmod.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 1999 The Apache Software Foundation. All rights
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met: * are met:
* *
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in * notice, this list of conditions and the following disclaimer in
@@ -17,15 +17,15 @@
* distribution. * distribution.
* *
* 3. The end-user documentation included with the redistribution, if * 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)." * Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself, * Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear. * if and wherever such third-party acknowlegements normally appear.
* *
* 4. The names "The Jakarta Project", "Ant", and "Apache Software * 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived * Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* from this software without prior written permission. For written
* permission, please contact apache@apache.org. * permission, please contact apache@apache.org.
* *
* 5. Products derived from this software may not be called "Apache" * 5. Products derived from this software may not be called "Apache"
@@ -54,15 +54,15 @@


package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import java.io.File;
import java.io.IOException;

import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.condition.Os; import org.apache.tools.ant.taskdefs.condition.Os;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet; import org.apache.tools.ant.types.PatternSet;


import java.io.File;
import java.io.IOException;


/** /**
* Chmod equivalent for unix-like environments. * Chmod equivalent for unix-like environments.
* *
@@ -70,13 +70,12 @@ import java.io.IOException;
* @author Mariusz Nowostawski (Marni) <a href="mailto:mnowostawski@infoscience.otago.ac.nz">mnowostawski@infoscience.otago.ac.nz</a> * @author Mariusz Nowostawski (Marni) <a href="mailto:mnowostawski@infoscience.otago.ac.nz">mnowostawski@infoscience.otago.ac.nz</a>
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/ */

public class Chmod extends ExecuteOn { public class Chmod extends ExecuteOn {


private FileSet defaultSet = new FileSet(); private FileSet defaultSet = new FileSet();
private boolean defaultSetDefined = false; private boolean defaultSetDefined = false;
private boolean havePerm = false; private boolean havePerm = false;
public Chmod() { public Chmod() {
super.setExecutable("chmod"); super.setExecutable("chmod");
super.setParallel(true); super.setParallel(true);
@@ -106,7 +105,7 @@ public class Chmod extends ExecuteOn {
defaultSetDefined = true; defaultSetDefined = true;
return defaultSet.createInclude(); return defaultSet.createInclude();
} }
/** /**
* add a name entry on the exclude list * add a name entry on the exclude list
*/ */
@@ -148,7 +147,7 @@ public class Chmod extends ExecuteOn {
/** /**
* Sets whether default exclusions should be used or not. * Sets whether default exclusions should be used or not.
* *
* @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
* @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
* should be used, "false"|"off"|"no" when they * should be used, "false"|"off"|"no" when they
* shouldn't be used. * shouldn't be used.
*/ */
@@ -156,13 +155,13 @@ public class Chmod extends ExecuteOn {
defaultSetDefined = true; defaultSetDefined = true;
defaultSet.setDefaultexcludes(useDefaultExcludes); defaultSet.setDefaultexcludes(useDefaultExcludes);
} }
protected void checkConfiguration() { protected void checkConfiguration() {
if (!havePerm) { if (!havePerm) {
throw new BuildException("Required attribute perm not set in chmod",
location);
throw new BuildException("Required attribute perm not set in chmod",
location);
} }
if (defaultSetDefined && defaultSet.getDir(project) != null) { if (defaultSetDefined && defaultSet.getDir(project) != null) {
addFileset(defaultSet); addFileset(defaultSet);
} }
@@ -172,8 +171,7 @@ public class Chmod extends ExecuteOn {
public void execute() throws BuildException { public void execute() throws BuildException {
if (defaultSetDefined || defaultSet.getDir(project) == null) { if (defaultSetDefined || defaultSet.getDir(project) == null) {
super.execute(); super.execute();
}
else if (isValidOs()) {
} else if (isValidOs()) {
// we are chmodding the given directory // we are chmodding the given directory
createArg().setValue(defaultSet.getDir(project).getPath()); createArg().setValue(defaultSet.getDir(project).getPath());
Execute execute = prepareExec(); Execute execute = prepareExec();
@@ -188,18 +186,18 @@ public class Chmod extends ExecuteOn {
} }
} }
} }


public void setExecutable(String e) { public void setExecutable(String e) {
throw new BuildException(taskType+" doesn\'t support the executable attribute", location);
throw new BuildException(taskType + " doesn\'t support the executable attribute", location);
} }


public void setCommand(String e) {
throw new BuildException(taskType+" doesn\'t support the command attribute", location);
public void setCommand(Commandline cmdl) {
throw new BuildException(taskType + " doesn\'t support the command attribute", location);
} }


public void setSkipEmptyFilesets(boolean skip) { public void setSkipEmptyFilesets(boolean skip) {
throw new BuildException(taskType+" doesn\'t support the skipemptyfileset attribute", location);
throw new BuildException(taskType + " doesn\'t support the skipemptyfileset attribute", location);
} }


protected boolean isValidOs() { protected boolean isValidOs() {


Loading…
Cancel
Save