summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Tool/javac.xml
blob: a6c08b21f58cfb5ab506fe9365db2465433fd82a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!--
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation

This file is processed by the bin/SConsDoc.py module.
See its __doc__ string for a discussion of the format.
-->
<tool name="javac">
<summary>
Sets construction variables for the &javac; compiler.
</summary>
<sets>
JAVAC
JAVACFLAGS
JAVACCOM
JAVACLASSSUFFIX
JAVASUFFIX
JAVABOOTCLASSPATH
JAVACLASSPATH
JAVASOURCEPATH
</sets>
<uses>
JAVACCOMSTR
</uses>
</tool>

<builder name="Java">
<summary>
Builds one or more Java class files.
The sources may be any combination of explicit
<filename>.java</filename> files,
or directory trees which will be scanned
for <filename>.java</filename> files.

SCons will parse each source <filename>.java</filename> file
to find the classes
(including inner classes)
defined within that file,
and from that figure out the
target <filename>.class</filename> files that will be created.
The class files will be placed underneath
the specified target directory.

SCons will also search each Java file
for the Java package name,
which it assumes can be found on a line
beginning with the string
<literal>package</literal>
in the first column;
the resulting <filename>.class</filename> files
will be placed in a directory reflecting
the specified package name.
For example,
the file
<filename>Foo.java</filename>
defining a single public
<classname>Foo</classname>
class and
containing a package name of
<classname>sub.dir</classname>
will generate a corresponding
<filename>sub/dir/Foo.class</filename>
class file.

Examples:

<example>
env.Java(target = 'classes', source = 'src')
env.Java(target = 'classes', source = ['src1', 'src2'])
env.Java(target = 'classes', source = ['File1.java', 'File2.java'])
</example>

Java source files can use the native encoding for the underlying OS.
Since SCons compiles in simple ASCII mode by default,
the compiler will generate warnings about unmappable characters,
which may lead to errors as the file is processed further.
In this case, the user must specify the <literal>LANG</literal>
environment variable to tell the compiler what encoding is used.
For portibility, it's best if the encoding is hard-coded
so that the compile will work if it is done on a system
with a different encoding.

<example>
env = Environment()
env['ENV']['LANG'] = 'en_GB.UTF-8'
</example>
</summary>
</builder>

<cvar name="JAVABOOTCLASSPATH">
<summary>
Specifies the list of directories that
will be added to the
&javac; command line
via the <option>-bootclasspath</option> option.
The individual directory names will be
separated by the operating system's path separate character
(<filename>:</filename> on UNIX/Linux/POSIX,
<filename>;</filename> on Windows).
</summary>
</cvar>

<cvar name="JAVAC">
<summary>
The Java compiler.
</summary>
</cvar>

<cvar name="JAVACCOM">
<summary>
The command line used to compile a directory tree containing
Java source files to
corresponding Java class files.
Any options specified in the &cv-link-JAVACFLAGS; construction variable
are included on this command line.
</summary>
</cvar>

<cvar name="JAVACCOMSTR">
<summary>
The string displayed when compiling
a directory tree of Java source files to
corresponding Java class files.
If this is not set, then &cv-link-JAVACCOM; (the command line) is displayed.

<example>
env = Environment(JAVACCOMSTR = "Compiling class files $TARGETS from $SOURCES")
</example>
</summary>
</cvar>

<cvar name="JAVACFLAGS">
<summary>
General options that are passed to the Java compiler.
</summary>
</cvar>

<cvar name="JAVACLASSDIR">
<summary>
The directory in which Java class files may be found.
This is stripped from the beginning of any Java .class
file names supplied to the
<literal>JavaH</literal>
builder.
</summary>
</cvar>

<cvar name="JAVACLASSPATH">
<summary>
Specifies the list of directories that
will be searched for Java
<filename>.class</filename> file.
The directories in this list will be added to the
&javac; and &javah; command lines
via the <option>-classpath</option> option.
The individual directory names will be
separated by the operating system's path separate character
(<filename>:</filename> on UNIX/Linux/POSIX,
<filename>;</filename> on Windows).

Note that this currently just adds the specified
directory via the <option>-classpath</option> option.
&SCons; does not currently search the
&cv-JAVACLASSPATH; directories for dependency
<filename>.class</filename> files.
</summary>
</cvar>

<cvar name="JAVACLASSSUFFIX">
<summary>
The suffix for Java class files;
<filename>.class</filename>
by default.
</summary>
</cvar>

<cvar name="JAVASOURCEPATH">
<summary>
Specifies the list of directories that
will be searched for input
<filename>.java</filename> file.
The directories in this list will be added to the
&javac; command line
via the <option>-sourcepath</option> option.
The individual directory names will be
separated by the operating system's path separate character
(<filename>:</filename> on UNIX/Linux/POSIX,
<filename>;</filename> on Windows).

Note that this currently just adds the specified
directory via the <option>-sourcepath</option> option.
&SCons; does not currently search the
&cv-JAVASOURCEPATH; directories for dependency
<filename>.java</filename> files.
</summary>
</cvar>

<cvar name="JAVASUFFIX">
<summary>
The suffix for Java files;
<filename>.java</filename>
by default.
</summary>
</cvar>

<cvar name="JAVAVERSION">
<summary>
Specifies the Java version being used by the &b-Java; builder.
This is <emphasis>not</emphasis> currently used to select one
version of the Java compiler vs. another.
Instead, you should set this to specify the version of Java
supported by your &javac; compiler.
The default is <literal>1.4</literal>.

This is sometimes necessary because
Java 1.5 changed the file names that are created
for nested anonymous inner classes,
which can cause a mismatch with the files
that &SCons; expects will be generated by the &javac; compiler.
Setting &cv-JAVAVERSION; to <literal>1.5</literal>
(or <literal>1.6</literal>, as appropriate)
can make &SCons; realize that a Java 1.5 or 1.6
build is actually up to date.
</summary>
</cvar>