annotate src/org/ssdt_ohio/tools/ant/AddDependencyTask.java @ 5:de1522a9d4bc

Ignore missing target in adddependency
author smith@nwoca.org
date Mon, 08 Aug 2011 13:38:54 -0400
parents 82fc5e17cc59
children
rev   line source
0
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
1 package org.ssdt_ohio.tools.ant;
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
2
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
3 import org.apache.tools.ant.BuildException;
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
4 import org.apache.tools.ant.Project;
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
5 import org.apache.tools.ant.Target;
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
6 import org.apache.tools.ant.Task;
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
7
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
8 /** @author smith */
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
9 public class AddDependencyTask extends Task {
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
10
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
11 private String target;
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
12 private String depends;
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
13
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
14 @Override
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
15 public void execute() throws BuildException {
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
16 if (target == null) {
1
82fc5e17cc59 clean up task messages
smith@nwoca.org
parents: 0
diff changeset
17 throw new BuildException("'target' attribute is required");
0
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
18 }
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
19 if (depends == null) {
1
82fc5e17cc59 clean up task messages
smith@nwoca.org
parents: 0
diff changeset
20 throw new BuildException("'depends' attribute is required");
0
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
21 }
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
22
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
23 Target t = (Target) getProject().getTargets().get(target);
5
de1522a9d4bc Ignore missing target in adddependency
smith@nwoca.org
parents: 1
diff changeset
24 if (t != null) {
0
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
25
5
de1522a9d4bc Ignore missing target in adddependency
smith@nwoca.org
parents: 1
diff changeset
26 if (t.dependsOn(depends)) {
de1522a9d4bc Ignore missing target in adddependency
smith@nwoca.org
parents: 1
diff changeset
27 log(target + " already depends on " + depends, Project.MSG_VERBOSE);
de1522a9d4bc Ignore missing target in adddependency
smith@nwoca.org
parents: 1
diff changeset
28 } else {
de1522a9d4bc Ignore missing target in adddependency
smith@nwoca.org
parents: 1
diff changeset
29 log("Adding \"" + depends + "\" dependency to \"" + target + "\"", Project.MSG_VERBOSE);
0
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
30
5
de1522a9d4bc Ignore missing target in adddependency
smith@nwoca.org
parents: 1
diff changeset
31 t.addDependency(depends);
de1522a9d4bc Ignore missing target in adddependency
smith@nwoca.org
parents: 1
diff changeset
32 }
0
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
33 }
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
34 }
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
35
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
36 public void setTarget(String target) {
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
37 this.target = target;
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
38 }
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
39
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
40 public void setDepends(String depends) {
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
41 this.depends = depends;
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
42 }
1918a6aed50a Initial ant tasks for SSDT develkit
smith@nwoca.org
parents:
diff changeset
43 }