KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > thirdparty > ant > CopyFile


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2006 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
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 JavaDoc;
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 /**
40  * This class is responsible for copy files from one location to another.
41  *
42  * @author Brett Chaldecott
43  */

44 public class CopyFile extends Copy {
45     
46     /** Creates a new instance of CopyFile */
47     public CopyFile(File JavaDoc source, File JavaDoc dest) {
48         project = new Project();
49         
50         project.init();
51         taskType = "jar";
52         taskName = "rmic";
53         target = new Target();
54         Path path = new Path(project);
55         this.setFile(source);
56         this.setTofile(dest);
57     }
58     
59     
60     /**
61      * This method executes the copy.
62      *
63      * @exception AntException
64      */

65     public void copy() throws AntException {
66         AntListener listener = new AntListener();
67         project.addBuildListener(listener);
68         try {
69             super.execute();
70         } catch (Exception JavaDoc ex) {
71             throw new AntException("Failed to copy the file :" + ex.getMessage()
72                 + " [" + listener.getMessage() + "]",ex);
73         }
74     }
75 }
76
Popular Tags