source: release-kits/lirk3/resources/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 3.3 KB
Line 
1/*
2 * Copyright 2001-2005 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant.taskdefs.compilers;
19
20import org.apache.tools.ant.BuildException;
21import org.apache.tools.ant.Project;
22import org.apache.tools.ant.taskdefs.ExecuteJava;
23import org.apache.tools.ant.types.Commandline;
24import org.apache.tools.ant.types.Path;
25
26/**
27 * The implementation of the Java compiler for KJC.
28 * This is primarily a cut-and-paste from Jikes.java and
29 * DefaultCompilerAdapter.
30 *
31 * @since Ant 1.4
32 */
33public class Kjc extends DefaultCompilerAdapter {
34
35 /**
36 * Run the compilation.
37 *
38 * @exception BuildException if the compilation has problems.
39 */
40 public boolean execute() throws BuildException {
41 attributes.log("Using kjc compiler", Project.MSG_VERBOSE);
42 Commandline cmd = setupKjcCommand();
43 cmd.setExecutable("at.dms.kjc.Main");
44 ExecuteJava ej = new ExecuteJava();
45 ej.setJavaCommand(cmd);
46 return ej.fork(getJavac()) == 0;
47 }
48
49 /**
50 * setup kjc command arguments.
51 */
52 protected Commandline setupKjcCommand() {
53 Commandline cmd = new Commandline();
54
55 // generate classpath, because kjc doesn't support sourcepath.
56 Path classpath = getCompileClasspath();
57
58 if (deprecation == true) {
59 cmd.createArgument().setValue("-deprecation");
60 }
61
62 if (destDir != null) {
63 cmd.createArgument().setValue("-d");
64 cmd.createArgument().setFile(destDir);
65 }
66
67 // generate the clsspath
68 cmd.createArgument().setValue("-classpath");
69
70 Path cp = new Path(project);
71
72 // kjc don't have bootclasspath option.
73 if (bootclasspath != null && bootclasspath.size() > 0) {
74 cp.append(bootclasspath);
75 }
76
77 if (extdirs != null) {
78 cp.addExtdirs(extdirs);
79 }
80
81 cp.append(classpath);
82 if (compileSourcepath != null) {
83 cp.append(compileSourcepath);
84 } else {
85 cp.append(src);
86 }
87
88 cmd.createArgument().setPath(cp);
89
90 // kjc-1.5A doesn't support -encoding option now.
91 // but it will be supported near the feature.
92 if (encoding != null) {
93 cmd.createArgument().setValue("-encoding");
94 cmd.createArgument().setValue(encoding);
95 }
96
97 if (debug) {
98 cmd.createArgument().setValue("-g");
99 }
100
101 if (optimize) {
102 cmd.createArgument().setValue("-O2");
103 }
104
105 if (verbose) {
106 cmd.createArgument().setValue("-verbose");
107 }
108
109 addCurrentCompilerArgs(cmd);
110
111 logAndAddFilesToCompile(cmd);
112 return cmd;
113 }
114}
115
116
Note: See TracBrowser for help on using the repository browser.