Mercurial > public > ssdtant
comparison src/org/ssdt_ohio/tools/ant/ReplaceTargetTask.java @ 7:418ba4cfc553 tip
USASR-644: preserve dependencies in replaced target
author | smith@nwoca.org |
---|---|
date | Wed, 12 Oct 2011 18:12:17 -0400 |
parents | c989b9aa8820 |
children |
comparison
equal
deleted
inserted
replaced
6:c989b9aa8820 | 7:418ba4cfc553 |
---|---|
1 package org.ssdt_ohio.tools.ant; | 1 package org.ssdt_ohio.tools.ant; |
2 | 2 |
3 import java.util.Enumeration; | |
3 import org.apache.tools.ant.BuildException; | 4 import org.apache.tools.ant.BuildException; |
4 import org.apache.tools.ant.Project; | 5 import org.apache.tools.ant.Project; |
5 import org.apache.tools.ant.Target; | 6 import org.apache.tools.ant.Target; |
6 import org.apache.tools.ant.Task; | 7 import org.apache.tools.ant.Task; |
7 | 8 |
22 | 23 |
23 Target t = (Target) getProject().getTargets().get(target); | 24 Target t = (Target) getProject().getTargets().get(target); |
24 if (t == null) { | 25 if (t == null) { |
25 log(target + " to be replaced does not exist", Project.MSG_VERBOSE); | 26 log(target + " to be replaced does not exist", Project.MSG_VERBOSE); |
26 } else { | 27 } else { |
28 | |
27 Target withTarget = (Target) getProject().getTargets().get(with); | 29 Target withTarget = (Target) getProject().getTargets().get(with); |
28 if (withTarget == null) { | 30 if (withTarget == null) { |
29 log(with + " replacement target does not exist", Project.MSG_ERR); | 31 log(with + " replacement target does not exist", Project.MSG_ERR); |
30 } else { | 32 } else { |
31 Target newTarget = new Target(withTarget); | 33 Target newTarget = new Target(withTarget); |
34 for (Enumeration en = t.getDependencies(); en.hasMoreElements();) { | |
35 String dep = (String) en.nextElement(); | |
36 if (!newTarget.dependsOn(dep)) { | |
37 newTarget.addDependency(dep); | |
38 } | |
39 } | |
32 newTarget.setName(target); | 40 newTarget.setName(target); |
41 | |
33 getProject().addOrReplaceTarget(newTarget); | 42 getProject().addOrReplaceTarget(newTarget); |
34 | 43 |
35 log(target + " target replaced by " + with, Project.MSG_INFO); | 44 log(target + " target replaced by " + with, Project.MSG_INFO); |
45 | |
36 } | 46 } |
37 } | 47 } |
38 } | 48 } |
39 | 49 |
40 public void setTarget(String target) { | 50 public void setTarget(String target) { |