KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > build > ant > JavacTask


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.build.ant;
12
13 import org.eclipse.pde.internal.build.IXMLConstants;
14 import org.eclipse.pde.internal.build.Utils;
15
16 /**
17  * Wrapper class for the Ant javac task.
18  */

19 public class JavacTask implements ITask {
20
21     protected String JavaDoc classpathId;
22     protected String JavaDoc bootclasspath;
23     protected String JavaDoc destdir;
24     protected String JavaDoc failonerror;
25     protected String JavaDoc[] srcdir;
26     protected String JavaDoc verbose;
27     protected String JavaDoc includeAntRuntime;
28     protected String JavaDoc fork;
29     protected String JavaDoc debug;
30     protected String JavaDoc source;
31     protected String JavaDoc target;
32     protected String JavaDoc compileArgs;
33     protected String JavaDoc compileArgsFile;
34     protected String JavaDoc encoding;
35     protected String JavaDoc logExtension;
36
37     /**
38      * Default constructor for the class.
39      */

40     public JavacTask() {
41         super();
42     }
43
44     /**
45      * @see ITask#print(AntScript)
46      */

47     public void print(AntScript script) {
48         script.printTab();
49         script.print("<javac"); //$NON-NLS-1$
50
script.printAttribute("destdir", destdir, false); //$NON-NLS-1$
51
script.printAttribute("failonerror", failonerror, false); //$NON-NLS-1$
52
script.printAttribute("verbose", verbose, false); //$NON-NLS-1$
53
script.printAttribute("fork", fork, false); //$NON-NLS-1$
54
script.printAttribute("debug", debug, false); //$NON-NLS-1$
55
script.printAttribute("includeAntRuntime", includeAntRuntime, false); //$NON-NLS-1$
56
script.printAttribute("bootclasspath", bootclasspath, false); //$NON-NLS-1$
57
script.printAttribute("source", source, false); //$NON-NLS-1$
58
script.printAttribute("target", target, false); //$NON-NLS-1$
59
script.printAttribute("encoding", encoding, false); //$NON-NLS-1$
60
script.println(">"); //$NON-NLS-1$
61

62         script.indent++;
63
64         if (compileArgs != null) {
65             script.println("<compilerarg line=\"" + compileArgs + "\" compiler=\"" + Utils.getPropertyFormat(IXMLConstants.PROPERTY_BUILD_COMPILER) + "\"/>"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
66
}
67
68         script.println("<classpath refid=\"" + classpathId + "\" />"); //$NON-NLS-1$ //$NON-NLS-2$
69

70         for (int i = 0; i < srcdir.length; i++) {
71             script.printTab();
72             script.print("<src path="); //$NON-NLS-1$
73
script.printQuotes(srcdir[i]);
74             script.println("/>"); //$NON-NLS-1$
75
}
76
77         if (compileArgsFile != null) {
78             script.println("<compilerarg value=\"@" + compileArgsFile + "\" compiler=\"" + IXMLConstants.JDT_COMPILER_ADAPTER + "\"/>"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
79
}
80         if (destdir != null) {
81             script.println("<compilerarg line=\"-log '" + destdir + logExtension + "'\" compiler=\"" + IXMLConstants.JDT_COMPILER_ADAPTER + "\"/>"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
82
}
83         script.indent--;
84         script.printEndTag("javac"); //$NON-NLS-1$
85
}
86
87     /**
88      * Set the javac task classpath refid to be the given value.
89      * @param classpathId
90      */

91     public void setClasspathId(String JavaDoc classpathId) {
92         this.classpathId = classpathId;
93     }
94
95     /**
96      * Set the javac task boot classpath to be the given value.
97      *
98      * @param bootclasspath the boot classpath attribute
99      */

100     public void setBootClasspath(String JavaDoc bootclasspath) {
101         this.bootclasspath = bootclasspath;
102     }
103
104     /**
105      * Set the javac task destination directory to be the given value.
106      *
107      * @param destdir the destination directory
108      */

109     public void setDestdir(String JavaDoc destdir) {
110         this.destdir = destdir;
111     }
112
113     /**
114      * Set the javac task failOnError attribute to be the given value. Valid values
115      * are <code>"true"</code> and <code>"false"</code>.
116      *
117      * @param failonerror either <code>"true"</code> or <code>"false"</code>
118      */

119     public void setFailOnError(String JavaDoc failonerror) {
120         this.failonerror = failonerror;
121     }
122
123     /**
124      * Set the javac task includeAntRuntime attribute to be the given value. Valid
125      * values are <code>"no"</code> and <code>"yes"</code>.
126      *
127      * @param include either <code>"no"</code> or <code>"yes"</code>
128      */

129     public void setIncludeAntRuntime(String JavaDoc include) {
130         this.includeAntRuntime = include;
131     }
132
133     /**
134      * Set the javac task source directory attribute to be the given value.
135      *
136      * @param srcdir the source directory
137      */

138     public void setSrcdir(String JavaDoc[] srcdir) {
139         this.srcdir = srcdir;
140     }
141
142     /**
143      * Set the javac task verbose attribute to be the given value. Valid values
144      * are <code>"true"</code> and <code>"false"</code>.
145      *
146      * @param verbose either <code>"true"</code> or <code>"false"</code>
147      */

148     public void setVerbose(String JavaDoc verbose) {
149         this.verbose = verbose;
150     }
151
152     /**
153      * Set the javac task fork attribute to be the given value. Valid values
154      * are <code>"true"</code> and <code>"false"</code>.
155      *
156      * @param fork either <code>"true"</code> or <code>"false"</code>
157      */

158     public void setFork(String JavaDoc fork) {
159         this.fork = fork;
160     }
161
162     /**
163      * Set the javac task debug attribute to be the given value. Valid values
164      * are <code>"on"</code> and <code>"off"</code>.
165      *
166      * @param debug either <code>"on"</code> or <code>"off"</code>
167      */

168     public void setDebug(String JavaDoc debug) {
169         this.debug = debug;
170     }
171
172     /**
173      * Set the javac task source attribute to be the given value.
174      *
175      * @param source either <code>"1.3"</code> or <code>"1.4"</code>
176      */

177     public void setSource(String JavaDoc source) {
178         this.source = source;
179     }
180
181     /**
182      * Set the javac task target attribute to be the given value.
183      *
184      * @param target either <code>"1.3"</code> or <code>"1.4"</code>
185      */

186     public void setTarget(String JavaDoc target) {
187         this.target = target;
188     }
189
190     public void setCompileArgs(String JavaDoc args) {
191         this.compileArgs = args;
192     }
193
194     public void setEncoding(String JavaDoc encoding) {
195         this.encoding = encoding;
196     }
197
198     public void setLogExtension(String JavaDoc extension) {
199         this.logExtension = extension;
200     }
201     
202     public void setCompileArgsFile(String JavaDoc file) {
203         this.compileArgsFile = file;
204     }
205 }
206
Popular Tags