Browse Source

remove issigned task, make it a condition only

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277065 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 20 years ago
parent
commit
81d29e52f1
5 changed files with 6 additions and 100 deletions
  1. +0
    -95
      src/main/org/apache/tools/ant/taskdefs/ConditionAndTask.java
  2. +4
    -3
      src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
  3. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/defaults.properties
  4. +1
    -0
      src/main/org/apache/tools/ant/types/defaults.properties
  5. +1
    -1
      src/main/org/apache/tools/ant/types/selectors/SignedSelector.java

+ 0
- 95
src/main/org/apache/tools/ant/taskdefs/ConditionAndTask.java View File

@@ -1,95 +0,0 @@
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.condition.Condition;

/**
* Abstract task to allow defintion of a task or a condition.
* It has property and value (for the property) attributes.
*
* @since Ant 1.7
*
* @ant.task category="control"
*/
public abstract class ConditionAndTask extends Task implements Condition {

private String property;
private String value = "true";

/**
* Set the name of the property which will be set if the particular resource
* is available.
*
* @param property the name of the property to set.
*/
public void setProperty(String property) {
this.property = property;
}

/**
* Set the value to be given to the property if the desired resource is
* available.
*
* @param value the value to be given.
*/
public void setValue(String value) {
this.value = value;
}

/**
* This method should be overridden by derived classes.
* It is used by eval() to evaluate the condition.
* @return true if the condition passes, false otherwise.
*/
protected abstract boolean evaluate();

/**
* This method evaluates the condition. It calls evaluate in the
* derived class.
* It sets the property if a property is present and if the
* evaluate returns true.
* @return true if the condition passes, false otherwise.
*/
public boolean eval() {
if (evaluate()) {
if (property != null) {
getProject().setNewProperty(property, value);
}
return true;
} else {
return false;
}
}

/**
* Entry point when operating as a task.
*
* @exception BuildException if the task is not configured correctly.
*/
public void execute() throws BuildException {
if (property == null) {
throw new BuildException("property attribute is required",
getLocation());
}
eval();
}

}

src/main/org/apache/tools/ant/taskdefs/IsSigned.java → src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java View File

@@ -14,10 +14,11 @@
* limitations under the License.
*
*/
package org.apache.tools.ant.taskdefs;
package org.apache.tools.ant.taskdefs.condition;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.DataType;
import java.io.File;
import java.io.IOException;
import java.util.zip.ZipEntry;
@@ -30,7 +31,7 @@ import java.util.Enumeration;
* particular signature; otherwise the file is checked for the
* existence of any signature.
*/
public class IsSigned extends ConditionAndTask {
public class IsSigned extends DataType implements Condition {

private static final String SIG_START = "META-INF/";
private static final String SIG_END = ".SF";
@@ -63,7 +64,7 @@ public class IsSigned extends ConditionAndTask {
* specified, if the file contains a signature.
* @return true if the file is signed.
*/
protected boolean evaluate() {
public boolean eval() {
if (file == null) {
throw new BuildException("The file attribute must be set.");
}

+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/defaults.properties View File

@@ -80,7 +80,6 @@ defaultexcludes=org.apache.tools.ant.taskdefs.DefaultExcludes
presetdef=org.apache.tools.ant.taskdefs.PreSetDef
macrodef=org.apache.tools.ant.taskdefs.MacroDef
nice=org.apache.tools.ant.taskdefs.Nice
issigned=org.apache.tools.ant.taskdefs.IsSigned
libraries=org.apache.tools.ant.taskdefs.repository.Libraries

# optional tasks


+ 1
- 0
src/main/org/apache/tools/ant/types/defaults.properties View File

@@ -34,5 +34,6 @@ scriptfilter=org.apache.tools.ant.types.optional.ScriptFilter
propertyset=org.apache.tools.ant.types.PropertySet
assertions=org.apache.tools.ant.types.Assertions
concatfilter=org.apache.tools.ant.filters.ConcatFilter
issigned=org.apache.tools.ant.taskdefs.condition.IsSigned
ispingable=org.apache.tools.ant.taskdefs.optional.condition.IsPingable
mavenrepository=org.apache.tools.ant.taskdefs.optional.repository.MavenRepository

+ 1
- 1
src/main/org/apache/tools/ant/types/selectors/SignedSelector.java View File

@@ -18,7 +18,7 @@
package org.apache.tools.ant.types.selectors;
import java.io.File;
import org.apache.tools.ant.types.DataType;
import org.apache.tools.ant.taskdefs.IsSigned;
import org.apache.tools.ant.taskdefs.condition.IsSigned;

/**
* Selector that chooses files based on whether they are signed or not.


Loading…
Cancel
Save