Retrotranslator 转换1.5的class到1.4的class

南门鸿畴
2023-12-01

build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="all" >
    <path id="compile.classpath">
         <fileset dir="../../tomcat5.5.15/webapps/ROOT/WEB-INF/lib" includes="**/*.jar"/>
         <fileset dir="./lib_Retrotranslator" includes="*.jar"/>
         <pathelement location="F:\Server\Web\jakarta-tomcat-4.1.30\common\lib\servlet.jar"/>
    </path>

    <patternset id="compilered.resources">
        <exclude name="**/?*.class"/>
    </patternset>

    <target name="jdk14">
        <taskdef name="retrotranslator" classpathref="compile.classpath"
                 classname="net.sf.retrotranslator.transformer.RetrotranslatorTask"/>
        <jdk14jar jarname="jar-name"/>
        <jdk14jar jarname="spring-2.0"/>
        <jdk14jar jarname="hibernate-annotations-3.2.1.ga"/>
        <jdk14jar jarname="aspectjrt-1.5.2a"/>
        <jdk14jar jarname="aspectjweaver-1.5.2a"/>
        <jdk14jar jarname="persistence-api-1.0"/>
    </target> 

     <target name="jdk14src" depends="jdk14">
        <taskdef name="retrotranslator" classpathref="compile.classpath"
                 classname="net.sf.retrotranslator.transformer.RetrotranslatorTask"/>
        <retrotranslator destdir="classes" verify="true">
            <fileset dir="../../tomcat5.5.15/webapps/ROOT/WEB-INF/classes" includes="**/*.class"/>
            <classpath location="${jdk14_home}/jre/lib/rt.jar"/>
            <classpath location="${jdk14_home}/jre/lib/jce.jar"/>
            <classpath refid="compile.classpath"/>
        </retrotranslator>
    </target>

     <macrodef name="jdk14jar">
        <attribute name="jarname"/>
        <sequential>
         <fail message="${jdk14_home} didn't exist, edit build.properties to reset the Jdk14_home propertity">
            <condition>
                <not>
                    <available file="${jdk14_home}" type="dir"/>
                </not>
            </condition>
        </fail>
        <retrotranslator srcjar="../../tomcat5.5.15/webapps/ROOT/WEB-INF/lib/@{jarname}.jar" destjar="./lib/@{jarname}-jdk14.jar" verify="true" failonwarning="Off">
            <classpath location="${jdk14_home}/jre/lib/rt.jar"/>
            <classpath refid="compile.classpath"/>
        </retrotranslator>
        </sequential>
     </macrodef>

     <target name="resources">
        <copy todir="classes">
            <fileset dir="../../tomcat5.5.15/webapps/ROOT/WEB-INF/classes">
                <patternset refid="compilered.resources"/>
            </fileset>
        </copy>
     </target>
     <target name="all" depends="jdk14src,resources">
     </target>
</project>

build-SQLinForm.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- 用 Retrotranslator 把上面编译的Class文件转换成JVM1.4的Class文件 -->
<project basedir="." default="convert-SQLinForm_jar" name="convert-SQLinForm15to14">
    <target name="convert-SQLinForm_jar">
      <!--
      <delete>
            <fileset dir="." includes="SQLinForm-jdk14.jar" />
        </delete>
        <mkdir dir="classes_jdk_15" />
        <mkdir dir="classes_jdk_14" />
        <unzip src="SQLinForm.jar" dest="classes_jdk_15" />
        -->
      <taskdef name="retrotranslator" classname="net.sf.retrotranslator.transformer.RetrotranslatorTask">
        <classpath>
            <fileset dir="./Retrotranslator-1.2.9-bin">
                <include name="retrotranslator-transformer-1.2.9.jar" />
                <include name="retrotranslator-runtime-1.2.9.jar" />
                <include name="backport-util-concurrent-3.1.jar" />
            </fileset>
        </classpath>
    </taskdef>
        <retrotranslator target="1.4" destjar="build/SQLinForm-jdk14.jar" smart="true" verify="true" failonwarning="false">
            <!--<fileset dir="build/classes" includes="**/*.class" />-->
      <!--<jarfileset dir="build/lib" includes="**/*.jar" />-->
      <jarfileset dir="." includes="SQLinForm.jar" />
      <classpath>
        <fileset dir="D:\bea8\jdk142_11\jre\lib\" includes="**/*.jar"/>
        <fileset dir="./Retrotranslator-1.2.9-bin">
            <include name="retrotranslator-runtime-1.2.9.jar" />
            <include name="backport-util-concurrent-3.1.jar" />
        </fileset>
        <!--<fileset dir="lib" includes="**/*.jar"/>-->
      </classpath>
        </retrotranslator>
        <!--
        <jar destfile="SQLinForm-jdk14.jar" basedir="classes_jdk_14"
            update="true" />
        <delete dir="classes_jdk_14" />
        <delete dir="classes_jdk_15" />
        -->
    </target>
</project>

执行方式

ant -f build-SQLinForm.xml convert-SQLinForm_jar

同级目录下放置:Retrotranslator-1.2.9-bin 目录和待转的 SQLinForm.jar

 类似资料: