KickJava   Java API By Example, From Geeks To Geeks.

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


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  * JAR.java
20  *
21  * This object is responsible for the creation of java archives.
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.Jar;
35 import org.apache.tools.ant.types.Path;
36
37 /**
38  * This object is responsible for the creation of java archives.
39  *
40  * @author Brett Chaldecott
41  */

42 public class JAR extends Jar {
43     
44     /**
45      * Creates a new instance of JAR object that can be executed.
46      *
47      * @param source The source file.
48      * @param dest The target file.
49      */

50     public JAR(File JavaDoc source, File JavaDoc dest) {
51         project = new Project();
52         
53         project.init();
54         taskType = "jar";
55         taskName = "jar";
56         target = new Target();
57         Path path = new Path(project);
58         this.setBasedir(source);
59         this.setDestFile(dest);
60     }
61     
62     
63     /**
64      * This method archives the specified file.
65      *
66      * @exception AntException
67      */

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