2
* The Apache Software License, Version 1.1
4
* Copyright (c) 2001 The Apache Software Foundation. All rights
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
11
* 1. Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
14
* 2. Redistributions in binary form must reproduce the above copyright
15
* notice, this list of conditions and the following disclaimer in
16
* the documentation and/or other materials provided with the
19
* 3. The end-user documentation included with the redistribution, if
20
* any, must include the following acknowlegement:
21
* "This product includes software developed by the
22
* Apache Software Foundation (http://www.apache.org/)."
23
* Alternately, this acknowlegement may appear in the software itself,
24
* if and wherever such third-party acknowlegements normally appear.
26
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
27
* Foundation" must not be used to endorse or promote products derived
28
* from this software without prior written permission. For written
29
* permission, please contact apache@apache.org.
31
* 5. Products derived from this software may not be called "Apache"
32
* nor may "Apache" appear in their names without prior written
33
* permission of the Apache Group.
35
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47
* ====================================================================
49
* This software consists of voluntary contributions made by many
50
* individuals on behalf of the Apache Software Foundation. For more
51
* information on the Apache Software Foundation, please see
52
* <http://www.apache.org/>.
55
package org.apache.tools.ant.taskdefs.compilers;
57
import org.apache.tools.ant.BuildException;
58
import org.apache.tools.ant.Project;
59
import org.apache.tools.ant.types.*;
62
* The implementation of the jikes compiler.
63
* This is primarily a cut-and-paste from the original javac task before it
66
* @author James Davidson <a href="mailto:duncan@x180.com">duncan@x180.com</a>
67
* @author Robin Green <a href="mailto:greenrd@hotmail.com">greenrd@hotmail.com</a>
68
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
69
* @author <a href="mailto:jayglanville@home.com">J D Glanville</a>
71
public class Jikes extends DefaultCompilerAdapter {
74
* Performs a compile using the Jikes compiler from IBM..
75
* Mostly of this code is identical to doClassicCompile()
76
* However, it does not support all options like
77
* bootclasspath, extdirs, deprecation and so on, because
78
* there is no option in jikes and I don't understand
79
* what they should do.
81
* It has been successfully tested with jikes >1.10
83
* @author skanthak@muehlheim.de
85
public boolean execute() throws BuildException {
86
attributes.log("Using jikes compiler", Project.MSG_VERBOSE);
88
Path classpath = new Path(project);
90
// Jikes doesn't support bootclasspath dir (-bootclasspath)
91
// so we'll emulate it for compatibility and convenience.
92
if (bootclasspath != null) {
93
classpath.append(bootclasspath);
96
// Jikes doesn't support an extension dir (-extdir)
97
// so we'll emulate it for compatibility and convenience.
98
addExtdirsToClasspath(classpath);
100
if ( (bootclasspath == null) || (bootclasspath.size() == 0) ) {
101
// no bootclasspath, therefore, get one from the java runtime
102
includeJavaRuntime = true;
104
// there is a bootclasspath stated. By default, the
105
// includeJavaRuntime is false. If the user has stated a
106
// bootclasspath and said to include the java runtime, it's on
109
classpath.append(getCompileClasspath());
111
// Jikes has no option for source-path so we
112
// will add it to classpath.
113
classpath.append(src);
115
// if the user has set JIKESPATH we should add the contents as well
116
String jikesPath = System.getProperty("jikes.class.path");
117
if (jikesPath != null) {
118
classpath.append(new Path(project, jikesPath));
121
Commandline cmd = new Commandline();
122
cmd.setExecutable("jikes");
124
if (deprecation == true)
125
cmd.createArgument().setValue("-deprecation");
127
if (destDir != null) {
128
cmd.createArgument().setValue("-d");
129
cmd.createArgument().setFile(destDir);
132
cmd.createArgument().setValue("-classpath");
133
cmd.createArgument().setPath(classpath);
135
if (encoding != null) {
136
cmd.createArgument().setValue("-encoding");
137
cmd.createArgument().setValue(encoding);
140
cmd.createArgument().setValue("-g");
143
cmd.createArgument().setValue("-O");
146
cmd.createArgument().setValue("-verbose");
149
cmd.createArgument().setValue("-depend");
153
* Perhaps we shouldn't use properties for these
154
* three options (emacs mode, warnings and pedantic),
155
* but include it in the javac directive?
159
* Jikes has the nice feature to print error
160
* messages in a form readable by emacs, so
161
* that emacs can directly set the cursor
162
* to the place, where the error occured.
164
String emacsProperty = project.getProperty("build.compiler.emacs");
165
if (emacsProperty != null && Project.toBoolean(emacsProperty)) {
166
cmd.createArgument().setValue("+E");
170
* Jikes issues more warnings that javac, for
171
* example, when you have files in your classpath
172
* that don't exist. As this is often the case, these
173
* warning can be pretty annoying.
175
String warningsProperty = project.getProperty("build.compiler.warnings");
176
if (warningsProperty != null) {
177
attributes.log("!! the build.compiler.warnings property is deprecated. !!",
179
attributes.log("!! Use the nowarn attribute instead. !!",
181
if (!Project.toBoolean(warningsProperty)) {
182
cmd.createArgument().setValue("-nowarn");
184
} if (attributes.getNowarn()) {
188
* let the magic property win over the attribute for backwards
191
cmd.createArgument().setValue("-nowarn");
195
* Jikes can issue pedantic warnings.
197
String pedanticProperty = project.getProperty("build.compiler.pedantic");
198
if (pedanticProperty != null && Project.toBoolean(pedanticProperty)) {
199
cmd.createArgument().setValue("+P");
203
* Jikes supports something it calls "full dependency
204
* checking", see the jikes documentation for differences
205
* between -depend and +F.
207
String fullDependProperty = project.getProperty("build.compiler.fulldepend");
208
if (fullDependProperty != null && Project.toBoolean(fullDependProperty)) {
209
cmd.createArgument().setValue("+F");
212
int firstFileName = cmd.size();
213
logAndAddFilesToCompile(cmd);
215
return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;