1 23 24 package com.rift.coad.lib.thirdparty.ant; 26 27 import java.io.File ; 29 import org.apache.tools.ant.BuildException; 30 31 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 44 public class CopyFile extends Copy { 45 46 47 public CopyFile(File source, File 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 65 public void copy() throws AntException { 66 AntListener listener = new AntListener(); 67 project.addBuildListener(listener); 68 try { 69 super.execute(); 70 } catch (Exception ex) { 71 throw new AntException("Failed to copy the file :" + ex.getMessage() 72 + " [" + listener.getMessage() + "]",ex); 73 } 74 } 75 } 76 | Popular Tags |