0
|
1 package org.ssdt_ohio.tools.ant;
|
|
2
|
|
3 import org.apache.tools.ant.BuildException;
|
|
4 import org.apache.tools.ant.Project;
|
|
5 import org.apache.tools.ant.Target;
|
|
6 import org.apache.tools.ant.Task;
|
|
7
|
|
8 /** @author smith */
|
|
9 public class AddDependencyTask extends Task {
|
|
10
|
|
11 private String target;
|
|
12 private String depends;
|
|
13
|
|
14 @Override
|
|
15 public void execute() throws BuildException {
|
|
16 if (target == null) {
|
1
|
17 throw new BuildException("'target' attribute is required");
|
0
|
18 }
|
|
19 if (depends == null) {
|
1
|
20 throw new BuildException("'depends' attribute is required");
|
0
|
21 }
|
|
22
|
|
23 Target t = (Target) getProject().getTargets().get(target);
|
5
|
24 if (t != null) {
|
0
|
25
|
5
|
26 if (t.dependsOn(depends)) {
|
|
27 log(target + " already depends on " + depends, Project.MSG_VERBOSE);
|
|
28 } else {
|
|
29 log("Adding \"" + depends + "\" dependency to \"" + target + "\"", Project.MSG_VERBOSE);
|
0
|
30
|
5
|
31 t.addDependency(depends);
|
|
32 }
|
0
|
33 }
|
|
34 }
|
|
35
|
|
36 public void setTarget(String target) {
|
|
37 this.target = target;
|
|
38 }
|
|
39
|
|
40 public void setDepends(String depends) {
|
|
41 this.depends = depends;
|
|
42 }
|
|
43 }
|