KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jarg > JargTask


1 /* ====================================================================
2  * Copyright (c) 2002, Hidetoshi Ohuchi <hchacha@users.sourceforge.net>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * Neither the name of the hchacha nor the names of its contributors
17  * may be used to endorse or promote products derived from this
18  * software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  * ====================================================================
33  */

34 package jarg;
35
36 import java.util.ArrayList JavaDoc;
37
38 import org.apache.tools.ant.BuildException;
39 import org.apache.tools.ant.Task;
40
41 /**
42  * The Ant Task class of Java Archive Grinder (jarg) .
43  *
44  * Copyright (c) 2002,
45  * <A HREF="mailto:Hidetoshi Ohuchi <hchacha@users.sourceforge.net>">
46  * Hidetoshi Ohuchi &lt;hchacha@users.sourceforge.net&gt;</A><BR>
47  *
48  * @version $Id: JargTask.java,v 1.8 2003/02/10 17:46:14 hchacha Exp $
49  * @author Hidetoshi Ohuchi &lt;hchacha@users.sourceforge.net&gt;
50  */

51 public class JargTask extends Task {
52     // The method executing the task
53
public void execute() throws BuildException {
54         ArrayList JavaDoc lst = new ArrayList JavaDoc();
55
56         if (jarfile == null || jarfile.length() <= 0) {
57             throw new BuildException("jarfile is required.");
58         }
59         lst.add(jarfile);
60
61         if (verbose) { lst.add("-verbose"); }
62         if (verbosern) { lst.add("-verbosern"); }
63         if (verboseufm) { lst.add("-verboseufm"); }
64         if (verbosebco) { lst.add("-verbosebco"); }
65         if (verboseall) { lst.add("-verboseall"); }
66
67         if (showstat) { lst.add("-showstat"); }
68
69         if (nocomp) { lst.add("-nocomp"); }
70
71         if (normdir) { lst.add("-normdir"); }
72         if (normlv) { lst.add("-normlv"); }
73         if (normln) { lst.add("-normln"); }
74         if (normsf) { lst.add("-normsf"); }
75         if (normsy) { lst.add("-normsy"); }
76         if (normin) { lst.add("-normin"); }
77         if (normex) { lst.add("-normex"); }
78
79         if (nornc) { lst.add("-nornc"); }
80         if (nornf) { lst.add("-nornf"); }
81         if (nornm) { lst.add("-nornm"); }
82
83         if (nobco) { lst.add("-nobco"); }
84
85         if (rnlog != null) { lst.add("-rnlog"); lst.add(rnlog); }
86
87         if (excpp != null) { lst.add("-excpp"); lst.add(excpp); }
88         if (excpc != null) { lst.add("-excpc"); lst.add(excpc); }
89         if (excpf != null) { lst.add("-excpf"); lst.add(excpf); }
90         if (excpm != null) { lst.add("-excpm"); lst.add(excpm); }
91
92         if (j2me_prev != null) { lst.add("-j2me-prev"); lst.add(j2me_prev); }
93         if (j2me_cp != null) { lst.add("-j2me-cp"); lst.add(j2me_cp); }
94
95         if (main_cp != null) {
96             for (int i=0; i<main_cp.size(); i++) {
97                 lst.add("-main"); lst.add(main_cp.get(i));
98             }
99         }
100
101         String JavaDoc[] args = new String JavaDoc[lst.size()];
102         lst.toArray(args);
103         lst = null;
104         Jarg.main(args);
105     }
106
107     //
108
// properties
109
//
110

111     private String JavaDoc jarfile;
112     public void setJarFile(String JavaDoc val) { jarfile = val; }
113
114     private boolean verbose;
115     public void setVerbose(boolean val) { verbose = val; }
116
117     private boolean verbosern;
118     public void setVerbosern(boolean val) { verbosern = val; }
119
120     private boolean verboseufm;
121     public void setVerboseufm(boolean val) { verboseufm = val; }
122
123     private boolean verbosebco;
124     public void setVerbosebco(boolean val) { verbosebco = val; }
125
126     private boolean verboseall;
127     public void setVerboseall(boolean val) { verboseall = val; }
128
129     private boolean showstat; // show statistics
130
public void setShowstat(boolean val) { showstat = val; }
131
132     private boolean nocomp; // no commpressed output jar file
133
public void setNocomp(boolean val) { nocomp = val; }
134
135     private boolean normdir; // no remove directry entry in jar file
136
public void setNormdir(boolean val) { normdir = val; }
137
138     private boolean normlv; // no remove local variable
139
public void setNormlv(boolean val) { normlv = val; }
140
141     private boolean normln; // no remove line number
142
public void setNormln(boolean val) { normln = val; }
143
144     private boolean normsf; // no remove source file
145
public void setNormsf(boolean val) { normsf = val; }
146
147     private boolean normsy; // no remove 'Synthetic'
148
public void setNormsy(boolean val) { normsy = val; }
149
150     private boolean normin; // no remove 'InnerClasses'
151
public void setNormin(boolean val) { normin = val; }
152
153     private boolean normex; // no remove 'Exceptions'
154
public void setNormex(boolean val) { normex = val; }
155
156     private boolean nornc; // no rename class
157
public void setNornc(boolean val) { nornc = val; }
158
159     private boolean nornf; // no rename field
160
public void setNornf(boolean val) { nornf = val; }
161
162     private boolean nornm; // no rename method
163
public void setNornm(boolean val) { nornm = val; }
164
165     private boolean nobco; // no byte-code optimization
166
public void setNobco(boolean val) { nobco = val; }
167
168     private String JavaDoc rnlog; // rename log
169
public void setRnlog(String JavaDoc val) { rnlog = val; }
170
171     private String JavaDoc excpp; // list of excepting package
172
public void setExcpp(String JavaDoc val) { excpp = val; }
173
174     private String JavaDoc excpc; // list of excepting class
175
public void setExcpc(String JavaDoc val) { excpc = val; }
176
177     private String JavaDoc excpf; // list of excepting field
178
public void setExcpf(String JavaDoc val) { excpf = val; }
179
180     private String JavaDoc excpm; // list of excepting method
181
public void setExcpm(String JavaDoc val) { excpm = val; }
182
183     private String JavaDoc j2me_prev; // j2me preverify command path
184
public void setJ2me_prev(String JavaDoc val) { j2me_prev = val; }
185
186     private String JavaDoc j2me_cp; // j2me preverify class path
187
public void setJ2me_cp(String JavaDoc val) { j2me_cp = val; }
188
189     private ArrayList JavaDoc main_cp; // main class path
190
public void setMain(String JavaDoc val) {
191         if (main_cp == null) {
192             main_cp = new ArrayList JavaDoc();
193         }
194         main_cp.add(val);
195     }
196 }
197
Popular Tags