01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.sdlctools.applications.anttasks.builder.tools;
16:
17: import java.io.File;
18:
19: import org.apache.tools.ant.BuildException;
20: import org.apache.tools.ant.Project;
21: import org.apache.tools.ant.taskdefs.Mkdir;
22:
23: import com.metaboss.sdlctools.applications.anttasks.builder.MetaBossBuilderTask;
24: import com.metaboss.sdlctools.applications.anttasks.builder.ToolInvocationDefinition;
25: import com.metaboss.util.ObjectUtils;
26:
27: /** This definition is responsible for invocation of Mkdir standard ant target */
28: public class AntMkdirInvocationDefinition extends
29: ToolInvocationDefinition {
30: private String mDirectoryPath = null;
31:
32: /** Public constructor for the invocation */
33: public AntMkdirInvocationDefinition(MetaBossBuilderTask pOwnerTask,
34: String pTaskName) {
35: super (pOwnerTask, pTaskName);
36: }
37:
38: /** Setter for the path of the directory to be created */
39: public void setDirectoryPath(String pDirectoryPath) {
40: mDirectoryPath = pDirectoryPath;
41: }
42:
43: /** Gets the path of the directory to be created */
44: public String getDirectoryPath() {
45: if (mDirectoryPath == null)
46: throw new BuildException(
47: "Missing DirectoryPath, which is mandatory for ant task invocation.");
48: return mDirectoryPath;
49: }
50:
51: /** Overridden to compare details of the invocation */
52: public boolean equals(Object pOther) {
53: if (this == pOther)
54: return true;
55: if (pOther instanceof AntMkdirInvocationDefinition) {
56: AntMkdirInvocationDefinition lOther = (AntMkdirInvocationDefinition) pOther;
57: if (!ObjectUtils.equals(mDirectoryPath,
58: lOther.mDirectoryPath))
59: return false;
60: return true;
61: }
62: return false;
63: }
64:
65: /** This method will have to invoke the generator */
66: public void invoke() throws BuildException {
67: MetaBossBuilderTask lOwnerTask = getOwnerTask();
68: Project lThisProject = getOwnerTask().getProject();
69: // Now create and execute the java compiler task
70: Mkdir lMkdirTask = (Mkdir) lThisProject.createTask("mkdir");
71: lMkdirTask.setTaskName(lOwnerTask.getTaskName());
72: lMkdirTask.setDir(new File(getDirectoryPath()));
73: lMkdirTask.execute();
74: }
75: }
|