Ant 编译 JDK 源码
2011-04-05 16:43
246 查看
整理了一下编译JDK源码的Ant脚本。发现用新一点的JDK编译旧的版本更容易,比如用jdk1.6.0_25编译jdk1.6.0_21。如果直接用jdk1.6.0_21编译自身代码,不是缺这个就是没那个,颇为麻烦。切到jdk1.6.0_25后,一下就编译通过了。
<project name="create rt_debug.jar" default="createJar" basedir=".">
<!-- *************************************************************** -->
<!-- Set-Up of propertys -->
<!-- *************************************************************** -->
<property name="project.build" location="build" />
<property name="project.src" location="${project.build}/src" />
<property name="project.classes" location="${project.build}/classes" />
<property name="project.dist" location="${project.build}/dist" />
<property name="JAVA_SOURCE" value="C:/Dev/Software/Java/jdk1.6.0_21" />
<property name="JAVA_COMPILER" value="C:/Dev/Software/Java/jdk1.6.0_25/fastdebug" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.6" />
<property name="source" value="1.6" />
<property environment="env" />
<!-- *************************************************************** -->
<!-- Initialize the bulid environment. -->
<!-- *************************************************************** -->
<target name="init">
<!-- Create the time stamp -->
<tstamp />
</target>
<!-- *************************************************************** -->
<!-- Set-Up of classpath -->
<!-- *************************************************************** -->
<path id="JavaLibraries">
<pathelement location="${project.classes}" />
<fileset dir="${JAVA_COMPILER}/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${JAVA_COMPILER}/jre/lib">
<include name="**/*.jar" />
</fileset>
</path>
<path id="project.classpath">
<path refid="JavaLibraries" />
</path>
<!-- *************************************************************** -->
<!-- Clean the bulid environment. -->
<!-- *************************************************************** -->
<target name="clean" depends="init">
<delete dir="${project.build}" quiet="true" />
<mkdir dir="${project.build}" />
</target>
<!-- *************************************************************** -->
<!-- Unpacd the source code package. -->
<!-- *************************************************************** -->
<target name="unpack" depends="init, clean">
<unzip src=\'#\'" /src.zip" dest="${project.src}" />
</target>
<!-- ****************************************************************** -->
<!-- Compile the source code. -->
<!-- ******************************************************************* -->
<target name="build" depends="unpack">
<echo message="Compile ${ant.project.name}" />
<mkdir dir="${project.classes}" />
<javac classpathref="project.classpath" srcdir="${project.src}" destdir="${project.classes}" debug="true" debuglevel="${debuglevel}" source="${source}" target="${target}" fork="true" memoryMaximumSize="512m">
<include name="**/*.java" />
</javac>
</target>
<!-- ****************************************************************** -->
<!-- Create jar package. -->
<!-- ******************************************************************* -->
<target name="createJar" depends="build">
<mkdir dir="${project.dist}" />
<jar jarfile="${project.dist}/rt_debug.jar" compress="false">
<fileset dir="${project.classes}" />
</jar>
</target>
</project>
<project name="create rt_debug.jar" default="createJar" basedir=".">
<!-- *************************************************************** -->
<!-- Set-Up of propertys -->
<!-- *************************************************************** -->
<property name="project.build" location="build" />
<property name="project.src" location="${project.build}/src" />
<property name="project.classes" location="${project.build}/classes" />
<property name="project.dist" location="${project.build}/dist" />
<property name="JAVA_SOURCE" value="C:/Dev/Software/Java/jdk1.6.0_21" />
<property name="JAVA_COMPILER" value="C:/Dev/Software/Java/jdk1.6.0_25/fastdebug" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.6" />
<property name="source" value="1.6" />
<property environment="env" />
<!-- *************************************************************** -->
<!-- Initialize the bulid environment. -->
<!-- *************************************************************** -->
<target name="init">
<!-- Create the time stamp -->
<tstamp />
</target>
<!-- *************************************************************** -->
<!-- Set-Up of classpath -->
<!-- *************************************************************** -->
<path id="JavaLibraries">
<pathelement location="${project.classes}" />
<fileset dir="${JAVA_COMPILER}/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${JAVA_COMPILER}/jre/lib">
<include name="**/*.jar" />
</fileset>
</path>
<path id="project.classpath">
<path refid="JavaLibraries" />
</path>
<!-- *************************************************************** -->
<!-- Clean the bulid environment. -->
<!-- *************************************************************** -->
<target name="clean" depends="init">
<delete dir="${project.build}" quiet="true" />
<mkdir dir="${project.build}" />
</target>
<!-- *************************************************************** -->
<!-- Unpacd the source code package. -->
<!-- *************************************************************** -->
<target name="unpack" depends="init, clean">
<unzip src=\'#\'" /src.zip" dest="${project.src}" />
</target>
<!-- ****************************************************************** -->
<!-- Compile the source code. -->
<!-- ******************************************************************* -->
<target name="build" depends="unpack">
<echo message="Compile ${ant.project.name}" />
<mkdir dir="${project.classes}" />
<javac classpathref="project.classpath" srcdir="${project.src}" destdir="${project.classes}" debug="true" debuglevel="${debuglevel}" source="${source}" target="${target}" fork="true" memoryMaximumSize="512m">
<include name="**/*.java" />
</javac>
</target>
<!-- ****************************************************************** -->
<!-- Create jar package. -->
<!-- ******************************************************************* -->
<target name="createJar" depends="build">
<mkdir dir="${project.dist}" />
<jar jarfile="${project.dist}/rt_debug.jar" compress="false">
<fileset dir="${project.classes}" />
</jar>
</target>
</project>
相关文章推荐
- 为ant指定编译java源码的jdk版本
- 为ant指定编译java源码的jdk版本
- ubuntu12.04编译android源码环境搭建____安装JDK 1.6
- win7下Ant编译Zookeeper源码为Eclipse工程
- ant编译 tomcat源码 导入 eclispe
- intellij idea加载go开发插件源码时报错Error:ant: Cannot run 'patch-version' target: JDK '<unknown>' not found
- 利用ant命令的source参数在jdk1.5环境下编译jdk1.4兼容的类
- Android源码编译时jdk冲突解决办法
- 解决jdk1.6已经安装,编译android源码报错问题
- tomcat-9.0.及jdk-1.7源码包编译安装
- ubuntu 编译android 源码Open_jdk 和oracle_jdk配置
- 重新编译jdk源码,启用debug信息
- You asked for an OpenJDK 7 build but your----Android源码编译之JDK下载问题
- 编译hadoop-0.20.2源码时执行ant eclipse-files出现.eclipse.templates does not exist问题解决方案
- Ubuntu11下android 源码编译 step by step -1 安装ubuntu和jdk
- 经验之Ant编译源码,停了
- JDK源码重新编译——支持eclipse调试JDK源码--转载
- ant 编译 spring3 源码, 导入 eclipse
- 使用ant编译openacs源码
- 无需eclipse无需ant,直接在android源码中混淆编译