You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2007/05/14 17:31:25 UTC
svn commit: r537880 -
/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
Author: mbenson
Date: Mon May 14 08:31:24 2007
New Revision: 537880
URL: http://svn.apache.org/viewvc?view=rev&rev=537880
Log:
early exit for empty substring with optional verbose log message
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java?view=diff&rev=537880&r1=537879&r2=537880
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java Mon May 14 08:31:24 2007
@@ -23,6 +23,7 @@
import java.io.InputStreamReader;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.util.FileUtils;
@@ -34,11 +35,28 @@
*/
public class ResourceContains implements Condition {
+ private Project project;
private String substring;
private Resource resource;
private boolean casesensitive = true;
/**
+ * Set this condition's Project.
+ * @param project Project
+ */
+ public void setProject(Project project) {
+ this.project = project;
+ }
+
+ /**
+ * Get this condition's Project.
+ * @return Project
+ */
+ public Project getProject() {
+ return project;
+ }
+
+ /**
* Sets the resource to search
* @param r
*/
@@ -70,6 +88,13 @@
if (resource == null || substring == null) {
throw new BuildException("both resource and substring are required "
+ "in <resourcecontains>");
+ }
+
+ if (substring.length() == 0) {
+ if (getProject() != null) {
+ getProject().log("ResourceContains: substring is empty; returning true", Project.MSG_VERBOSE);
+ }
+ return true;
}
if (resource.getSize() == 0) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org