01: /*
02: * CoadunationLib: The coaduntion implementation library.
03: * Copyright (C) 2006 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18: *
19: * CopyFile.java
20: *
21: * This class is responsible for copy files from one location to another.
22: */
23:
24: // package path
25: package com.rift.coad.lib.thirdparty.ant;
26:
27: // java imports
28: import java.io.File;
29: import org.apache.tools.ant.BuildException;
30:
31: // ant imports
32: import org.apache.tools.ant.Project;
33: import org.apache.tools.ant.Target;
34: import org.apache.tools.ant.taskdefs.Copy;
35: import org.apache.tools.ant.types.Path;
36: import org.apache.tools.ant.BuildEvent;
37:
38: /**
39: * This class is responsible for copy files from one location to another.
40: *
41: * @author Brett Chaldecott
42: */
43: public class CopyFile extends Copy {
44:
45: /** Creates a new instance of CopyFile */
46: public CopyFile(File source, File dest) {
47: project = new Project();
48:
49: project.init();
50: taskType = "jar";
51: taskName = "rmic";
52: target = new Target();
53: Path path = new Path(project);
54: this .setFile(source);
55: this .setTofile(dest);
56: }
57:
58: /**
59: * This method executes the copy.
60: *
61: * @exception AntException
62: */
63: public void copy() throws AntException {
64: AntListener listener = new AntListener();
65: project.addBuildListener(listener);
66: try {
67: super .execute();
68: } catch (Exception ex) {
69: throw new AntException("Failed to copy the file :"
70: + ex.getMessage() + " [" + listener.getMessage()
71: + "]", ex);
72: }
73: }
74: }
|