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: * 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;
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 source, File 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: * This method archives the specified file.
64: *
65: * @exception AntException
66: */
67: public void archive() throws AntException {
68: AntListener listener = new AntListener();
69: project.addBuildListener(listener);
70: try {
71: super .execute();
72: } catch (Exception ex) {
73: throw new AntException("Failed to archive :"
74: + ex.getMessage() + " [" + listener.getMessage()
75: + "]", ex);
76: }
77: }
78: }
|