# HG changeset patch
# User smith@nwoca.org
# Date 1318438772 14400
# Node ID c989b9aa8820a71ba01580798d945f4e2e55c07d
# Parent de1522a9d4bcf3bc26883afb57918321019dc05d
USASR-644: Add ant task to replace existing ant targets
diff -r de1522a9d4bc -r c989b9aa8820 build.xml
--- a/build.xml Mon Aug 08 13:38:54 2011 -0400
+++ b/build.xml Wed Oct 12 12:59:32 2011 -0400
@@ -1,74 +1,10 @@
-
-
-
-
-
-
-
-
Builds, tests, and runs the project SSDT Ant Tasks.
-
+
+
+
+
diff -r de1522a9d4bc -r c989b9aa8820 src/org/ssdt_ohio/tools/ant/ReplaceTargetTask.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/ssdt_ohio/tools/ant/ReplaceTargetTask.java Wed Oct 12 12:59:32 2011 -0400
@@ -0,0 +1,47 @@
+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 ReplaceTargetTask extends Task {
+
+ private String target;
+ private String with;
+
+ @Override
+ public void execute() throws BuildException {
+ if (target == null) {
+ throw new BuildException("'target' attribute is required");
+ }
+ if (with == null) {
+ throw new BuildException("'with' attribute is required");
+ }
+
+ Target t = (Target) getProject().getTargets().get(target);
+ if (t == null) {
+ log(target + " to be replaced does not exist", Project.MSG_VERBOSE);
+ } else {
+ Target withTarget = (Target) getProject().getTargets().get(with);
+ if (withTarget == null) {
+ log(with + " replacement target does not exist", Project.MSG_ERR);
+ } else {
+ Target newTarget = new Target(withTarget);
+ newTarget.setName(target);
+ getProject().addOrReplaceTarget(newTarget);
+
+ log(target + " target replaced by " + with, Project.MSG_INFO);
+ }
+ }
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public void setWith(String with) {
+ this.with = with;
+ }
+}
diff -r de1522a9d4bc -r c989b9aa8820 src/org/ssdt_ohio/tools/ant/antlib.xml
--- a/src/org/ssdt_ohio/tools/ant/antlib.xml Mon Aug 08 13:38:54 2011 -0400
+++ b/src/org/ssdt_ohio/tools/ant/antlib.xml Wed Oct 12 12:59:32 2011 -0400
@@ -1,4 +1,5 @@
+
\ No newline at end of file