1 28 29 package com.idaremedia.antx.condition.solo; 30 31 import org.apache.tools.ant.BuildException; 32 import org.apache.tools.ant.Project; 33 import org.apache.tools.ant.Task; 34 import org.apache.tools.ant.taskdefs.condition.Condition; 35 36 import com.idaremedia.antx.AntX; 37 import com.idaremedia.antx.apis.AntLibFriendly; 38 import com.idaremedia.antx.apis.BuildAssertionException; 39 import com.idaremedia.antx.helpers.TaskHandle; 40 import com.idaremedia.antx.helpers.Tk; 41 import com.idaremedia.antx.ownhelpers.TaskExaminer; 42 import com.idaremedia.antx.starters.TaskSet; 43 44 64 65 public final class BatchChecksTaskSet extends TaskSet implements Condition, AntLibFriendly 66 { 67 70 public BatchChecksTaskSet() 71 { 72 super(AntX.conditions+"BatchChecks:"); 73 } 74 75 76 77 81 public final void setFailProperty(String property) 82 { 83 require_(!Tk.isWhitespace(property),"setfailp- nonwspc"); 84 m_failProperty = property; 85 } 86 87 88 92 public final String getFailProperty() 93 { 94 return m_failProperty; 95 } 96 97 98 99 103 protected boolean includeTask(TaskHandle taskH) 104 { 105 Class c = TaskExaminer.trueClass(taskH.getTask()); 106 return c!=null && BooleanRule.class.isAssignableFrom(c); 107 } 108 109 110 111 116 protected void performNestedTasks() throws BuildException 117 { 118 Task[] tasks = getTasks(); 119 int signals = 0; 120 for (int i=0;i<tasks.length;i++) { 121 try { 122 tasks[i].perform(); 123 } catch(RuntimeException rtX) { 124 signals++; 125 if (!(rtX instanceof BuildAssertionException)) { log(rtX.getMessage(), Project.MSG_ERR); 127 } 128 } 129 } 130 if (signals>0) { 131 String what = String.valueOf(signals); 132 String msg = getAntXMsg("brul.batch.asserts.failed",what); 133 if (m_failProperty!=null) { 134 checkIfProperty_(m_failProperty,true); 135 getProject().setNewProperty(m_failProperty, what); 136 log("BatchCheck false; setting failure property "+m_failProperty+ 137 " to "+what, Project.MSG_DEBUG); 138 } else { 139 log(msg, Project.MSG_WARN); 140 } 141 throw new BuildAssertionException(msg,getLocation()); 142 } 143 } 144 145 146 152 public boolean eval() 153 { 154 execute(); 155 return true; 156 } 157 158 159 private String m_failProperty;} 161 162 | Popular Tags |