ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/AntTasks/source/net/douglasthrift/anttasks/CommandTask.java
(Generate patch)

Comparing:
AntTasks/source/net/douglasthrift/anttasks/AAPT.java (file contents), Revision 1109 by douglas, 2008-11-05T21:07:38-08:00 vs.
AntTasks/source/net/douglasthrift/anttasks/CommandTask.java (file contents), Revision 1112 by douglas, 2008-11-07T00:35:05-08:00

# Line 1 | Line 1
1 < // AAPT Ant Task
1 > // Command Task
2   //
3   // Douglas Thrift
4   //
# Line 21 | Line 21
21  
22   package net.douglasthrift.anttasks;
23  
24 + import java.io.File;
25 +
26   import org.apache.tools.ant.Task;
27 + import org.apache.tools.ant.taskdefs.ExecTask;
28 + import org.apache.tools.ant.types.Path;
29 + import org.apache.tools.ant.types.Reference;
30  
31 < public class AAPT extends Task
31 > public abstract class CommandTask extends Task
32   {
33 +        protected ExecTask command_;
34 +
35 +        @Override
36          public void execute()
37          {
38 +                command_.execute();
39 +        }
40 +
41 +        protected void command(String command)
42 +        {
43 +                command_ = (ExecTask)getProject().createTask("exec");
44 +
45 +                command_.setTaskName(getTaskName());
46 +                command_.setExecutable(command);
47 +                command_.setFailonerror(true);
48 +        }
49 +
50 +        protected void argument(File file)
51 +        {
52 +                command_.createArg().setFile(file);
53 +        }
54 +
55 +        protected void argument(Path path)
56 +        {
57 +                command_.createArg().setPath(path);
58 +        }
59 +
60 +        protected void argument(Reference reference)
61 +        {
62 +                command_.createArg().setPathref(reference);
63 +        }
64 +
65 +        protected void argument(String value)
66 +        {
67 +                command_.createArg().setValue(value);
68 +        }
69 +
70 +        protected void arguments(String line)
71 +        {
72 +                command_.createArg().setLine(line);
73 +        }
74 +
75 +        protected void arguments(Object... objects)
76 +        {
77 +                for (Object object : objects)
78 +                        if (object instanceof File)
79 +                                argument((File)object);
80 +                        else if (object instanceof Path)
81 +                                argument((Path)object);
82 +                        else if (object instanceof Reference)
83 +                                argument((Reference)object);
84 +                        else if (object instanceof String)
85 +                                argument((String)object);
86 +                        else
87 +                                assert (false);
88          }
89   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines