diff src/org/ssdt_ohio/tools/ant/AddDependencyTask.java @ 0:1918a6aed50a

Initial ant tasks for SSDT develkit
author smith@nwoca.org
date Sat, 16 Apr 2011 16:06:16 -0400
parents
children 82fc5e17cc59
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/ssdt_ohio/tools/ant/AddDependencyTask.java	Sat Apr 16 16:06:16 2011 -0400
@@ -0,0 +1,43 @@
+package org.ssdt_ohio.tools.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.Task;
+
+/** @author smith */
+public class AddDependencyTask extends Task {
+
+  
+    private String target;
+    private String depends;
+
+    @Override
+    public void execute() throws BuildException {
+        if (target == null) {
+            throw new BuildException("target attribute is required");
+        }
+        if (depends == null) {
+            throw new BuildException("depends attribute is required");
+        }
+
+        Target t = (Target) getProject().getTargets().get(target);
+
+        if (t.dependsOn(depends)) {
+            log(target +" already depends on " + depends, Project.MSG_VERBOSE);
+        } else {
+            log("Adding \"" + depends + "\" dependency to \"" + target + "\"", Project.MSG_VERBOSE);
+
+            t.addDependency(depends);
+        }
+    }
+
+    public void setTarget(String target) {
+        this.target = target;
+    }
+
+    public void setDepends(String depends) {
+        this.depends = depends;
+    }
+}
+