📅  最后修改于: 2020-12-26 13:59:45             🧑  作者: Mango
Ant Javac任务用于编译Java源文件。它扫描源目录和目标目录以编译源文件。它只有在两者之一时才编译。班级不存在或。该类早于Java文件。
如果Java源文件位于任何软件包中,则源文件应具有目录层次结构。
Attribute | Description | Required |
---|---|---|
srcdir | Source Java file. | Yes |
destdir | Destination to store the class files. | No |
includes | A list of patterns of files that must be included. | No |
includesfile | Each line of this file is taken to be an include pattern. | No |
excludes | A list of patterns of files that must be excluded. | No; defaults to default excludes or none if defaultexcludes is no |
excludesfile | Each line of this file is taken to be an exclude pattern. | No |
classpath | The classpath to use. | No |
bootclasspath | Path of bootstrap class files. | No |
extdirs | Path of installed extensions. | No |
encoding | Encoding of source files. | No |
nowarn | It is used to pass -nowarn switch to the compiler. | No |
debug | To debug file during compilation. | No |
debuglevel | Set level of debug file. | No |
optimize | Indicates whether source should be compiled with optimization. | No |
deprecation | Compile with with deprecation information. | No |
verbose | Asks the compiler for verbose output. | No |
depend | Enables dependency tracking for compilers that support it. | No |
includeAntRuntime | Whether to include the Ant run-time libraries in the classpath or not. | No |
fork | Whether to execute javac using the JDK compiler externally or not. | No |
executable | Complete path to the javac executable. | No |
memoryInitialSize | Set initial memory size. | No |
memoryMaximumSize | The maximum size of the memory for the underlying JVM. | No |
以下代码编译Java源文件并将类文件存储到目标目录中。
// build.xml
此示例将编译位于srcdir中的所有Java源文件,并将.class存储到destdir目录中。因为打开了调试模式,它将以调试模式编译Java源代码。
此示例将编译位于srcdir中的所有Java源文件,并将.class存储到destdir目录中。源级别为1.8,.class文件将在Jdk 1.8下运行。