Source Code Cross Referenced for Jikes.java in  » Build » ANT » org » apache » tools » ant » taskdefs » compilers » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.ant.taskdefs.compilers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        package org.apache.tools.ant.taskdefs.compilers;
020:
021:        import org.apache.tools.ant.BuildException;
022:        import org.apache.tools.ant.Project;
023:        import org.apache.tools.ant.types.Commandline;
024:        import org.apache.tools.ant.types.Path;
025:
026:        /**
027:         * The implementation of the jikes compiler.
028:         * This is primarily a cut-and-paste from the original javac task before it
029:         * was refactored.
030:         *
031:         * @since Ant 1.3
032:         */
033:        public class Jikes extends DefaultCompilerAdapter {
034:
035:            /**
036:             * Performs a compile using the Jikes compiler from IBM.
037:             * Mostly of this code is identical to doClassicCompile()
038:             * However, it does not support all options like
039:             * extdirs, deprecation and so on, because
040:             * there is no option in jikes and I don't understand
041:             * what they should do.
042:             *
043:             * It has been successfully tested with jikes >1.10.
044:             * @return true if the compilation succeeded
045:             * @throws BuildException on error
046:             */
047:            public boolean execute() throws BuildException {
048:                attributes.log("Using jikes compiler", Project.MSG_VERBOSE);
049:
050:                Commandline cmd = new Commandline();
051:
052:                // For -sourcepath, use the "sourcepath" value if present.
053:                // Otherwise default to the "srcdir" value.
054:                Path sourcepath = null;
055:                if (compileSourcepath != null) {
056:                    sourcepath = compileSourcepath;
057:                } else {
058:                    sourcepath = src;
059:                }
060:                // If the buildfile specifies sourcepath="", then don't
061:                // output any sourcepath.
062:                if (sourcepath.size() > 0) {
063:                    cmd.createArgument().setValue("-sourcepath");
064:                    cmd.createArgument().setPath(sourcepath);
065:                }
066:
067:                Path classpath = new Path(project);
068:
069:                if (bootclasspath == null || bootclasspath.size() == 0) {
070:                    // no bootclasspath, therefore, get one from the java runtime
071:                    includeJavaRuntime = true;
072:                } else {
073:                    // there is a bootclasspath stated.  By default, the
074:                    // includeJavaRuntime is false.  If the user has stated a
075:                    // bootclasspath and said to include the java runtime, it's on
076:                    // their head!
077:                }
078:                classpath.append(getCompileClasspath());
079:
080:                // if the user has set JIKESPATH we should add the contents as well
081:                String jikesPath = System.getProperty("jikes.class.path");
082:                if (jikesPath != null) {
083:                    classpath.append(new Path(project, jikesPath));
084:                }
085:
086:                if (extdirs != null && extdirs.size() > 0) {
087:                    cmd.createArgument().setValue("-extdirs");
088:                    cmd.createArgument().setPath(extdirs);
089:                }
090:
091:                String exec = getJavac().getExecutable();
092:                cmd.setExecutable(exec == null ? "jikes" : exec);
093:
094:                if (deprecation) {
095:                    cmd.createArgument().setValue("-deprecation");
096:                }
097:
098:                if (destDir != null) {
099:                    cmd.createArgument().setValue("-d");
100:                    cmd.createArgument().setFile(destDir);
101:                }
102:
103:                cmd.createArgument().setValue("-classpath");
104:                cmd.createArgument().setPath(classpath);
105:
106:                if (encoding != null) {
107:                    cmd.createArgument().setValue("-encoding");
108:                    cmd.createArgument().setValue(encoding);
109:                }
110:                if (debug) {
111:                    String debugLevel = attributes.getDebugLevel();
112:                    if (debugLevel != null) {
113:                        cmd.createArgument().setValue("-g:" + debugLevel);
114:                    } else {
115:                        cmd.createArgument().setValue("-g");
116:                    }
117:                } else {
118:                    cmd.createArgument().setValue("-g:none");
119:                }
120:                if (optimize) {
121:                    cmd.createArgument().setValue("-O");
122:                }
123:                if (verbose) {
124:                    cmd.createArgument().setValue("-verbose");
125:                }
126:                if (depend) {
127:                    cmd.createArgument().setValue("-depend");
128:                }
129:
130:                if (target != null) {
131:                    cmd.createArgument().setValue("-target");
132:                    cmd.createArgument().setValue(target);
133:                }
134:
135:                /**
136:                 * XXX
137:                 * Perhaps we shouldn't use properties for these
138:                 * three options (emacs mode, warnings and pedantic),
139:                 * but include it in the javac directive?
140:                 */
141:
142:                /**
143:                 * Jikes has the nice feature to print error
144:                 * messages in a form readable by emacs, so
145:                 * that emacs can directly set the cursor
146:                 * to the place, where the error occurred.
147:                 */
148:                String emacsProperty = project
149:                        .getProperty("build.compiler.emacs");
150:                if (emacsProperty != null && Project.toBoolean(emacsProperty)) {
151:                    cmd.createArgument().setValue("+E");
152:                }
153:
154:                /**
155:                 * Jikes issues more warnings that javac, for
156:                 * example, when you have files in your classpath
157:                 * that don't exist. As this is often the case, these
158:                 * warning can be pretty annoying.
159:                 */
160:                String warningsProperty = project
161:                        .getProperty("build.compiler.warnings");
162:                if (warningsProperty != null) {
163:                    attributes.log(
164:                            "!! the build.compiler.warnings property is "
165:                                    + "deprecated. !!", Project.MSG_WARN);
166:                    attributes.log("!! Use the nowarn attribute instead. !!",
167:                            Project.MSG_WARN);
168:                    if (!Project.toBoolean(warningsProperty)) {
169:                        cmd.createArgument().setValue("-nowarn");
170:                    }
171:                }
172:                if (attributes.getNowarn()) {
173:                    cmd.createArgument().setValue("-nowarn");
174:                }
175:
176:                /**
177:                 * Jikes can issue pedantic warnings.
178:                 */
179:                String pedanticProperty = project
180:                        .getProperty("build.compiler.pedantic");
181:                if (pedanticProperty != null
182:                        && Project.toBoolean(pedanticProperty)) {
183:                    cmd.createArgument().setValue("+P");
184:                }
185:
186:                /**
187:                 * Jikes supports something it calls "full dependency
188:                 * checking", see the jikes documentation for differences
189:                 * between -depend and +F.
190:                 */
191:                String fullDependProperty = project
192:                        .getProperty("build.compiler.fulldepend");
193:                if (fullDependProperty != null
194:                        && Project.toBoolean(fullDependProperty)) {
195:                    cmd.createArgument().setValue("+F");
196:                }
197:
198:                if (attributes.getSource() != null) {
199:                    cmd.createArgument().setValue("-source");
200:                    String source = attributes.getSource();
201:                    if (source.equals("1.1") || source.equals("1.2")) {
202:                        // support for -source 1.1 and -source 1.2 has been
203:                        // added with JDK 1.4.2, Jikes doesn't like it
204:                        attributes.log("Jikes doesn't support '-source "
205:                                + source + "', will use '-source 1.3' instead");
206:                        cmd.createArgument().setValue("1.3");
207:                    } else {
208:                        cmd.createArgument().setValue(source);
209:                    }
210:                }
211:
212:                addCurrentCompilerArgs(cmd);
213:
214:                int firstFileName = cmd.size();
215:
216:                Path boot = getBootClassPath();
217:                if (boot.size() > 0) {
218:                    cmd.createArgument().setValue("-bootclasspath");
219:                    cmd.createArgument().setPath(boot);
220:                }
221:
222:                logAndAddFilesToCompile(cmd);
223:
224:                return executeExternalCompile(cmd.getCommandline(),
225:                        firstFileName) == 0;
226:            }
227:
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.