Ant 1900개가 넘는 java컴파일시 Ant의 설정

황제낙엽 2007.02.28 10:43 조회 수 : 678 추천:73

sitelink1 http://blog.naver.com/pluggers/150003316374 
sitelink2  
sitelink3  

 

2000개가 넘는 자바파일을 Ant로 컴파일 시킬려면..

compile:
     [echo] Compile Start !! --- 2006-04-10 05:16:33
    [javac] Compiling 2144 source files to C:lafBuilderworkspaceRmsWEB-INFclasses
    [javac] java.lang.OutOfMemoryError
    [javac] Exception in thread "main"

BUILD FAILED
C:lafBuilderworkspaceRmsbuild.xml:33: Compile failed; see the compiler error output for details.

위와 같은 에러메시지가 난다.. OutOfMemoryError 젠장..

이럴때 Ant의 javac 프라퍼티에 fork="yes" memoryMaximumSize="256m" 추가해서 컴파일 하면 된다.

Parameters

 

Attribute Description Required
srcdir Location of the java files. (See the note below.) Yes, unless nested elements are present.
destdir Location to store the class files. No
includes Comma- or space-separated list of files (may be specified using wildcard patterns) that must be included; all .java files are included when omitted. No
includesfile The name of a file that contains a list of files to include (may be specified using wildcard patterns). No
excludes Comma- or space-separated list of files (may be specified using wildcard patterns) that must be excluded; no files (except default excludes) are excluded when omitted. No
excludesfile The name of a file that contains a list of files to exclude (may be specified using wildcard patterns). No
classpath The classpath to use. No
sourcepath The sourcepath to use; defaults to the value of the srcdir attribute (or nested elements). To suppress the sourcepath switch, use sourcepath="". No
bootclasspath Location of bootstrap class files. No
classpathref The classpath to use, given as a reference to a path defined elsewhere. No
sourcepathref The sourcepath to use, given as a reference to a path defined elsewhere. No
bootclasspathref Location of bootstrap class files, given as a reference to a path defined elsewhere. No
extdirs Location of installed extensions. No
encoding Encoding of source files. (Note: gcj doesn't support this option yet.) No
nowarn Indicates whether the -nowarn switch should be passed to the compiler; defaults to off. No
debug Indicates whether source should be compiled with debug information; defaults to off. If set to off, -g:none will be passed on the command line for compilers that support it (for other compilers, no command line argument will be used). If set to true, the value of the debuglevel attribute determines the command line argument. No
debuglevel Keyword list to be appended to the -g command-line switch. This will be ignored by all implementations except modern, classic(ver >= 1.2) and jikes. Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. If debuglevel is not specified, by default, nothing will be appended to -g. If debug is not turned on, this attribute will be ignored. No
optimize Indicates whether source should be compiled with optimization; defaults to off. No
deprecation Indicates whether source should be compiled with deprecation information; defaults to off. No
target Generate class files for specific VM version (e.g., 1.1 or 1.2). Note that the default value depends on the JVM that is running Ant. In particular, if you use JDK 1.4+ the generated classes will not be usable for a 1.1 Java VM unless you explicitly set this attribute to the value 1.1 (which is the default value for JDK 1.1 to 1.3). We highly recommend to always specify this attribute. No
verbose Asks the compiler for verbose output; defaults to no. No
depend Enables dependency-tracking for compilers that support this (jikes and classic). No
includeAntRuntime Whether to include the Ant run-time libraries in the classpath; defaults to yes. No
includeJavaRuntime Whether to include the default run-time libraries from the executing VM in the classpath; defaults to no. No
fork Whether to execute javac using the JDK compiler externally; defaults to no. No
executable Complete path to the javac executable to use in case of fork="yes". Defaults to the compiler of the Java version that is currently running Ant. Ignored if fork="no".
Since Ant 1.6 this attribute can also be used to specify the path to the executable when using jikes, jvc, gcj or sj.
No
memoryInitialSize The initial size of the memory for the underlying VM, if javac is run externally; ignored otherwise. Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m) No
memoryMaximumSize The maximum size of the memory for the underlying VM, if javac is run externally; ignored otherwise. Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m) No
failonerror Indicates whether the build will continue even if there are compilation errors; defaults to true. No
source Value of the -source command-line switch; will be ignored by all implementations prior to javac1.4 (or modern when Ant is not running in a 1.3 VM) and jikes.
If you use this attribute together with jikes, you must make sure that your version of jikes supports the -source switch. By default, no -source argument will be used at all.
Note that the default value depends on the JVM that is running Ant. We highly recommend to always specify this attribute.
No
compiler The compiler implementation to use. If this attribute is not set, the value of the build.compiler property, if set, will be used. Otherwise, the default compiler for the current VM will be used. (See the above list of valid compilers.) No
listfiles Indicates whether the source files to be compiled will be listed; defaults to no. No
tempdir Where Ant should place temporary files. This is only used if the task is forked and the command line args length exceeds 4k. Since Ant 1.6. No; default is java.io.tmpdir.

출처 : http://ant.apache.org/manual/CoreTasks/javac.html

<target name="compile" depends="init">
    <echo message="Compile Start!! --- ${TODAY}" />
    <javac srcdir="${src.dir}" for="yes" memoryMaximumSize="256m" destdir="${classes.dir}">
        <classpath>
            <pathelement location="..." />
            <pathelement location="..." />
            <pathelement location="..." />
            <pathelement location="..." />
        </classpath>
    </javac>
    <echo message="Compile End!! --- ${TODAY}" />
</target>


compile:
     [echo] Compile Start !! --- 2006-04-10 05:19:48
    [javac] Compiling 2144 source files to C:lafBuilderworkspaceRmsWEB-INFclasses
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -deprecation for details.
     [echo] Compile End !!   --- 2006-04-10 05:19:48
BUILD SUCCESSFUL
Total time: 19 seconds