将ant脚本转换为gradle脚本

发布于 2024-11-15 06:29:44 字数 17393 浏览 2 评论 0原文

如何将ant脚本转换为gradle脚本? 你好, 你能帮我把ant脚本转换成gradle脚本吗?我是 gradle 的新用户。

<property name="pm-dir"                value="${PM-DIR}/${BUILD_NUM}" />
<property name="leis-dir"              value="${LEIS_DIR}/${BUILD_NUM}" />

<property name="proxy-name"             value="${PROXY_JAR_NAME}"/>
<property name="proxy-client-name"      value="${PROXY_CLIENT_JAR_NAME}"/>

<property environment="env"/>
<property name="java-home"              value="${env.JAVA_HOME}"/>

  <condition property="build-pm">
    <equals arg1="True" arg2="${BUILD_PM}" />
</condition>

<condition property="build-LEIS">
    <equals arg1="True" arg2="${BUILD_LEIS}" />
</condition>


<target name="build-LEIS-components" if="build-LEIS">

    <ant antfile="build.xml"
         target="clean"
         dir="${leis-dir}/LEIS"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="ejbdoclet"
         dir="${leis-dir}/LEIS/BusinessServices"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="jar"
         dir="${leis-dir}/LEIS"
         inheritAll="false"/>

    <ant antfile="build.xml"
         target="clean"
         dir="${leis-dir}/ETS/trunk/Entitlements"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="build"
         dir="${leis-dir}/ETS/trunk/Entitlements"
         inheritAll="false"/>

    <mkdir dir="${leis-dir}/JARS/APP-INF/lib/"/>

    <jar jarfile="${leis-dir}/JARS/APP-INF/lib/LEISConfig.jar">
        <fileset dir="LEIS/" includes="datetime.properties"/>
        <fileset dir="LEIS/" includes="log4j.properties"/>
        <manifest>
            <attribute name="Built-By" value="${user.name}"/>
        </manifest>
    </jar>
</target>


<!--========================================================================
Builds pm using the supplied RE build files, modified by us.
========================================================================-->
<target name="build-pm" if="build-pm">




    <!-- SPPResourceBundle Overrides -->
    <mkdir dir="${pm-dir}/pm2/deploy/propertyoverrides"/>
    <copy todir="${pm-dir}/pm2/deploy/propertyoverrides" overwrite="true">
        <fileset dir="olwpmconfig/propertyoverrides"/>
    </copy>

    <!-- copy build.properties into pm dir, complete with kodo key -->
    <copy file="olwpmconfig/build.properties"      todir="${pm-dir}/pm2/"            overwrite="true">
        <filterchain>         
               <replacetokens>
                   <token key="LOGGINGFLOOR" value="${PERFORMANCE_LOGGING_FLOOR}"/>
                   <token key="BEADIR" value="${BEA_HOME}"/>
               </replacetokens>
        </filterchain>
    </copy>

    <!--the actual Retail Express build scripts to create the pm-main.ear-->
    <echo message="Calling pm Build Script"/>
    <ant antfile='${pm-dir}/pm2/build/build.xml'          target='clean-build' inheritAll="false"/>

    <!--delete the extra copy of jdo.dtd-->
    <delete file="jdo.dtd" />

    <fileset id="required-pm-client-libs" dir="${pm-dir}/pm2/deploy/lib">
        <include name="*.jar"/>
        <include name="client/*.jar"/>
        <exclude name="*tests.jar"/>
    </fileset>

    <!-- Used to populate value of MANIFEST.MF Class-path attribute. Turns our set of "required" libs
     into a nice space separated string to place in the MANIFEST.MF. Property is used in the "dist"
     task's jar command. -->
    <pathconvert property="client-classpath"
                 refid="required-pm-client-libs"
                 pathsep=" "
                 dirsep="/">
        <map from="${pm-dir}/pm2/deploy/lib/" to=""/>
    </pathconvert>

    <jar update="true" jarfile="${pm-dir}/pm2/deploy/lib/pm-core.jar">
        <manifest>
            <attribute name="Class-Path" value="${client-classpath}"/>
            <attribute name="Main-Class" value="com.retailexp.pm.ui.util.SPPClientStartUp"/>
        </manifest>
    </jar>

    <!-- Creates a file Marimba/BigFix/WhatEver can use to track the version of pm installed on a machine -->
    <echo message="${pm_MAJOR_VERSION}.${BUILD_NUM}" file="${pm-dir}/pm2/deploy/lib/version.txt" append="false"/>

    <!-- Remove files we place on classpath from ears, Mantis 10624 -->
    <!-- pm -->
    <move file="${pm-dir}/pm2/deploy/dist/pm-main.ear" tofile="${pm-dir}/pm2/deploy/dist/old-pm-main.ear"/>
    <unzip src="${pm-dir}/pm2/deploy/dist/old-pm-main.ear" dest="${pm-dir}/pm2/deploy/dist/">
        <patternset>
            <include name="lib/pm-server-conf.jar"/>
        </patternset>
    </unzip>
    <move file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar" tofile="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar"/>
    <zip file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar">
        <zipfileset src="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar">
            <exclude name="log4j.properties"/>
            <exclude name="ehcache-transactional.xml"/>
        </zipfileset>
    </zip>
    <zip file="${pm-dir}/pm2/deploy/dist/pm-main.ear">
        <zipfileset src="${pm-dir}/pm2/deploy/dist/old-pm-main.ear">
            <exclude name="lib/pm-server-conf.jar"/>
        </zipfileset>
        <zipfileset dir="${pm-dir}/pm2/deploy/dist/lib/" includes="pm-server-conf.jar" fullpath="lib/pm-server-conf.jar"/>
    </zip>
    <!-- EDM -->
    <move file="${pm-dir}/pm2/deploy/dist/pm-edm.ear" tofile="${pm-dir}/pm2/deploy/dist/old-pm-edm.ear"/>
    <unzip src="${pm-dir}/pm2/deploy/dist/old-pm-edm.ear" dest="${pm-dir}/pm2/deploy/dist/">
        <patternset>
            <include name="lib/pm-server-conf.jar"/>
        </patternset>
    </unzip>
    <move file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar" tofile="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar"/>
    <zip file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar">
        <zipfileset src="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar">
            <exclude name="log4j.properties"/>
        </zipfileset>
    </zip>
    <zip file="${pm-dir}/pm2/deploy/dist/pm-edm.ear">
        <zipfileset src="${pm-dir}/pm2/deploy/dist/old-pm-edm.ear">
            <exclude name="lib/pm-server-conf.jar"/>
        </zipfileset>
        <zipfileset dir="${pm-dir}/pm2/deploy/dist/lib/" includes="pm-server-conf.jar" fullpath="lib/pm-server-conf.jar"/>
    </zip>
</target>

<!--========================================================================
Builds LEIS
========================================================================-->
<target name="build-proxy" if="build-LEIS">

    <!--copy deploy.properties with the proper jar names and locations-->
    <copy file="LEIS/deploy.properties"        todir="${leis-dir}/proxy/config/build/"    overwrite="true">
        <filterchain>
               <replacetokens>
                    <token key="pmCORE"            value="${pm_CORE_NAME}"/>
                    <token key="pmTRANSFER"        value="${pm_TRANSFER_NAME}"/>
                    <token key="PROXYJARNAME"       value="${PROXY_JAR_NAME}"/>
                    <token key="PROXYCLIENTJARNAME" value="${PROXY_CLIENT_JAR_NAME}"/>
                    <token key="PROXYLIBSDIR"       value="${leis-dir}/JARS/"/>
               </replacetokens>
        </filterchain>
    </copy>

     <ant antfile="build.xml" target="clean" dir="${leis-dir}/proxy" inheritAll="false" />
    <ant antfile="build.xml" target="prod-dist" dir="${leis-dir}/proxy" inheritAll="false">
        <property name="build.name" value="${pm_MAJOR_VERSION}.${BUILD_NUM}"/>
    </ant>

     <ear destfile="${ear-name}" appxml="LEIS/application.xml">
        <metainf dir="${leis-dir}/LEIS/conf/EAR/META-INF" includes="weblogic-application.xml"/>
        <fileset dir="${leis-dir}/JARS/"                   includes="*.jar"/>
        <fileset dir="${leis-dir}/JARS/"                   includes="APP-INF/**" excludes="APP-INF/lib/wlfullclient.jar"/>
    </ear>

    <!-- Place the proxy-client jar in the pm ear-->
    <zip update="true" destfile="${pm-dir}/pm2/deploy/dist/pm-main.ear">
        <zipfileset dir="${leis-dir}/proxy/dist/" includes="${proxy-client-name}" fullpath="APP-INF/lib/${proxy-client-name}"/>
    </zip>

</target>

<target name="build-cpc">
    <copy file="${pm-dir}/pm2/deploy/lib/${pm_TRANSFER_NAME}" todir="${leis-dir}/cpc-web-app/webapp/lib/cpc"/>
    <ant antfile="build.xml" target="build-all-environments" dir="${leis-dir}/cpc-web-app/webapp" inheritAll="false"/>
</target>

<target name="build-all">
    <antcall target="build-LEIS-components"/>
    <antcall target="build-pm"/>
    <antcall target="build-proxy"/>
    <antcall target="build-cpc"/>
</target>    </condition>

<condition property="build-LEIS">
    <equals arg1="True" arg2="${BUILD_LEIS}" />
</condition>


<target name="build-LEIS-components" if="build-LEIS">

    <!--Go through and build the LEIS modules-->
    <ant antfile="build.xml"
         target="clean"
         dir="${leis-dir}/LEIS"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="ejbdoclet"
         dir="${leis-dir}/LEIS/BusinessServices"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="jar"
         dir="${leis-dir}/LEIS"
         inheritAll="false"/>



    <ant antfile="build.xml"
         target="clean"
         dir="${leis-dir}/ETS/trunk/Entitlements"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="build"
         dir="${leis-dir}/ETS/trunk/Entitlements"
         inheritAll="false"/>


    <mkdir dir="${leis-dir}/JARS/APP-INF/lib/"/>


    <jar jarfile="${leis-dir}/JARS/APP-INF/lib/LEISConfig.jar">
        <fileset dir="LEIS/" includes="datetime.properties"/>
        <fileset dir="LEIS/" includes="log4j.properties"/>
        <manifest>
            <attribute name="Built-By" value="${user.name}"/>
        </manifest>
    </jar>
</target>


<target name="build-pm" if="build-pm">



    <mkdir dir="${pm-dir}/amp2/deploy/propertyoverrides"/>
    <copy todir="${pm-dir}/amp2/deploy/propertyoverrides" overwrite="true">
        <fileset dir="olwAMPconfig/propertyoverrides"/>
    </copy>

    <ant antfile='${pm-dir}/amp2/build/build.xml'          target='clean-build' inheritAll="false"/>

    <!--delete the extra copy of jdo.dtd-->
    <delete file="jdo.dtd" />

    <fileset id="required-amp-client-libs" dir="${pm-dir}/amp2/deploy/lib">
        <include name="*.jar"/>
        <include name="client/*.jar"/>
        <exclude name="*tests.jar"/>
    </fileset>

    <!-- Used to populate value of MANIFEST.MF Class-path attribute. Turns our set of "required" libs
     into a nice space separated string to place in the MANIFEST.MF. Property is used in the "dist"
     task's jar command. -->
    <pathconvert property="client-classpath"
                 refid="required-amp-client-libs"
                 pathsep=" "
                 dirsep="/">
        <map from="${pm-dir}/amp2/deploy/lib/" to=""/>
    </pathconvert>

    <jar update="true" jarfile="${pm-dir}/amp2/deploy/lib/amp-core.jar">
        <manifest>
            <attribute name="Class-Path" value="${client-classpath}"/>
            <attribute name="Main-Class" value="com.retailexp.amp.ui.util.SPPClientStartUp"/>
        </manifest>
    </jar>

    <!-- Creates a file Marimba/BigFix/WhatEver can use to track the version of AMP installed on a machine -->
    <echo message="${AMP_MAJOR_VERSION}.${BUILD_NUM}" file="${pm-dir}/amp2/deploy/lib/version.txt" append="false"/>

    <!-- Remove files we place on classpath from ears, Mantis 10624 -->
    <!-- AMP -->
    <move file="${pm-dir}/amp2/deploy/dist/amp-main.ear" tofile="${pm-dir}/amp2/deploy/dist/old-amp-main.ear"/>
    <unzip src="${pm-dir}/amp2/deploy/dist/old-amp-main.ear" dest="${pm-dir}/amp2/deploy/dist/">
        <patternset>
            <include name="lib/amp-server-conf.jar"/>
        </patternset>
    </unzip>
    <move file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar" tofile="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar"/>
    <zip file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar">
        <zipfileset src="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar">
            <exclude name="log4j.properties"/>
            <exclude name="ehcache-transactional.xml"/>
        </zipfileset>
    </zip>
    <zip file="${pm-dir}/amp2/deploy/dist/amp-main.ear">
        <zipfileset src="${pm-dir}/amp2/deploy/dist/old-amp-main.ear">
            <exclude name="lib/amp-server-conf.jar"/>
        </zipfileset>
        <zipfileset dir="${pm-dir}/amp2/deploy/dist/lib/" includes="amp-server-conf.jar" fullpath="lib/amp-server-conf.jar"/>
    </zip>
    <!-- EDM -->
    <move file="${pm-dir}/amp2/deploy/dist/amp-edm.ear" tofile="${pm-dir}/amp2/deploy/dist/old-amp-edm.ear"/>
    <unzip src="${pm-dir}/amp2/deploy/dist/old-amp-edm.ear" dest="${pm-dir}/amp2/deploy/dist/">
        <patternset>
            <include name="lib/amp-server-conf.jar"/>
        </patternset>
    </unzip>
    <move file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar" tofile="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar"/>
    <zip file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar">
        <zipfileset src="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar">
            <exclude name="log4j.properties"/>
        </zipfileset>
    </zip>
    <zip file="${pm-dir}/amp2/deploy/dist/amp-edm.ear">
        <zipfileset src="${pm-dir}/amp2/deploy/dist/old-amp-edm.ear">
            <exclude name="lib/amp-server-conf.jar"/>
        </zipfileset>
        <zipfileset dir="${pm-dir}/amp2/deploy/dist/lib/" includes="amp-server-conf.jar" fullpath="lib/amp-server-conf.jar"/>
    </zip>
</target>

<!--===============  Builds LEIS   ========================================================================-->
<target name="build-proxy" if="build-LEIS">


    <ant antfile="build.xml" target="clean" dir="${leis-dir}/proxy" inheritAll="false" />
    <ant antfile="build.xml" target="prod-dist" dir="${leis-dir}/proxy" inheritAll="false">
        <property name="build.name" value="${AMP_MAJOR_VERSION}.${BUILD_NUM}"/>
    </ant>

    <!--copy the proxy jar to the LEIS jars library-->
    <copy todir="${leis-dir}/JARS" flatten="true">
        <fileset dir="${leis-dir}/proxy/dist/" >
            <include name="${proxy-name}"/>
        </fileset>
    </copy>

    <!--create a directory to hold the LEIS ear contents-->
    <property name="ear.dir"            value="${leis-dir}/bin"/>
    <property name="ear-name"           value="${ear.dir}/LEIS_AMP.ear"/>
    <mkdir dir="${ear.dir}"/>

    <!--create the ear from the directories contents-->
    <ear destfile="${ear-name}" appxml="LEIS/application.xml">
        <metainf dir="${leis-dir}/LEIS/conf/EAR/META-INF" includes="weblogic-application.xml"/>
        <fileset dir="${leis-dir}/JARS/"                   includes="*.jar"/>
        <fileset dir="${leis-dir}/JARS/"                   includes="APP-INF/**" excludes="APP-INF/lib/wlfullclient.jar"/>
    </ear>

    <!-- Place the proxy-client jar in the amp ear-->
    <zip update="true" destfile="${pm-dir}/amp2/deploy/dist/amp-main.ear">
        <zipfileset dir="${leis-dir}/proxy/dist/" includes="${proxy-client-name}" fullpath="APP-INF/lib/${proxy-client-name}"/>
    </zip>

</target>

<target name="build-cpc">
    <copy file="${pm-dir}/amp2/deploy/lib/${AMP_TRANSFER_NAME}" todir="${leis-dir}/cpc-web-app/webapp/lib/cpc"/>
    <ant antfile="build.xml" target="build-all-environments" dir="${leis-dir}/cpc-web-app/webapp" inheritAll="false"/>
</target>

<!--=========================================    Build AMP and LEIS  --!>

<target name="build-all">
    <antcall target="build-LEIS-components"/>
    <antcall target="build-pm"/>
    <antcall target="build-proxy"/>
    <antcall target="build-cpc"/>
</target>

How do you convert ant script into gradle script?
Hi,
Can you please help me to convert ant script into gradle script. I am new user of gradle.

<property name="pm-dir"                value="${PM-DIR}/${BUILD_NUM}" />
<property name="leis-dir"              value="${LEIS_DIR}/${BUILD_NUM}" />

<property name="proxy-name"             value="${PROXY_JAR_NAME}"/>
<property name="proxy-client-name"      value="${PROXY_CLIENT_JAR_NAME}"/>

<property environment="env"/>
<property name="java-home"              value="${env.JAVA_HOME}"/>

  <condition property="build-pm">
    <equals arg1="True" arg2="${BUILD_PM}" />
</condition>

<condition property="build-LEIS">
    <equals arg1="True" arg2="${BUILD_LEIS}" />
</condition>


<target name="build-LEIS-components" if="build-LEIS">

    <ant antfile="build.xml"
         target="clean"
         dir="${leis-dir}/LEIS"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="ejbdoclet"
         dir="${leis-dir}/LEIS/BusinessServices"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="jar"
         dir="${leis-dir}/LEIS"
         inheritAll="false"/>

    <ant antfile="build.xml"
         target="clean"
         dir="${leis-dir}/ETS/trunk/Entitlements"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="build"
         dir="${leis-dir}/ETS/trunk/Entitlements"
         inheritAll="false"/>

    <mkdir dir="${leis-dir}/JARS/APP-INF/lib/"/>

    <jar jarfile="${leis-dir}/JARS/APP-INF/lib/LEISConfig.jar">
        <fileset dir="LEIS/" includes="datetime.properties"/>
        <fileset dir="LEIS/" includes="log4j.properties"/>
        <manifest>
            <attribute name="Built-By" value="${user.name}"/>
        </manifest>
    </jar>
</target>


<!--========================================================================
Builds pm using the supplied RE build files, modified by us.
========================================================================-->
<target name="build-pm" if="build-pm">




    <!-- SPPResourceBundle Overrides -->
    <mkdir dir="${pm-dir}/pm2/deploy/propertyoverrides"/>
    <copy todir="${pm-dir}/pm2/deploy/propertyoverrides" overwrite="true">
        <fileset dir="olwpmconfig/propertyoverrides"/>
    </copy>

    <!-- copy build.properties into pm dir, complete with kodo key -->
    <copy file="olwpmconfig/build.properties"      todir="${pm-dir}/pm2/"            overwrite="true">
        <filterchain>         
               <replacetokens>
                   <token key="LOGGINGFLOOR" value="${PERFORMANCE_LOGGING_FLOOR}"/>
                   <token key="BEADIR" value="${BEA_HOME}"/>
               </replacetokens>
        </filterchain>
    </copy>

    <!--the actual Retail Express build scripts to create the pm-main.ear-->
    <echo message="Calling pm Build Script"/>
    <ant antfile='${pm-dir}/pm2/build/build.xml'          target='clean-build' inheritAll="false"/>

    <!--delete the extra copy of jdo.dtd-->
    <delete file="jdo.dtd" />

    <fileset id="required-pm-client-libs" dir="${pm-dir}/pm2/deploy/lib">
        <include name="*.jar"/>
        <include name="client/*.jar"/>
        <exclude name="*tests.jar"/>
    </fileset>

    <!-- Used to populate value of MANIFEST.MF Class-path attribute. Turns our set of "required" libs
     into a nice space separated string to place in the MANIFEST.MF. Property is used in the "dist"
     task's jar command. -->
    <pathconvert property="client-classpath"
                 refid="required-pm-client-libs"
                 pathsep=" "
                 dirsep="/">
        <map from="${pm-dir}/pm2/deploy/lib/" to=""/>
    </pathconvert>

    <jar update="true" jarfile="${pm-dir}/pm2/deploy/lib/pm-core.jar">
        <manifest>
            <attribute name="Class-Path" value="${client-classpath}"/>
            <attribute name="Main-Class" value="com.retailexp.pm.ui.util.SPPClientStartUp"/>
        </manifest>
    </jar>

    <!-- Creates a file Marimba/BigFix/WhatEver can use to track the version of pm installed on a machine -->
    <echo message="${pm_MAJOR_VERSION}.${BUILD_NUM}" file="${pm-dir}/pm2/deploy/lib/version.txt" append="false"/>

    <!-- Remove files we place on classpath from ears, Mantis 10624 -->
    <!-- pm -->
    <move file="${pm-dir}/pm2/deploy/dist/pm-main.ear" tofile="${pm-dir}/pm2/deploy/dist/old-pm-main.ear"/>
    <unzip src="${pm-dir}/pm2/deploy/dist/old-pm-main.ear" dest="${pm-dir}/pm2/deploy/dist/">
        <patternset>
            <include name="lib/pm-server-conf.jar"/>
        </patternset>
    </unzip>
    <move file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar" tofile="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar"/>
    <zip file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar">
        <zipfileset src="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar">
            <exclude name="log4j.properties"/>
            <exclude name="ehcache-transactional.xml"/>
        </zipfileset>
    </zip>
    <zip file="${pm-dir}/pm2/deploy/dist/pm-main.ear">
        <zipfileset src="${pm-dir}/pm2/deploy/dist/old-pm-main.ear">
            <exclude name="lib/pm-server-conf.jar"/>
        </zipfileset>
        <zipfileset dir="${pm-dir}/pm2/deploy/dist/lib/" includes="pm-server-conf.jar" fullpath="lib/pm-server-conf.jar"/>
    </zip>
    <!-- EDM -->
    <move file="${pm-dir}/pm2/deploy/dist/pm-edm.ear" tofile="${pm-dir}/pm2/deploy/dist/old-pm-edm.ear"/>
    <unzip src="${pm-dir}/pm2/deploy/dist/old-pm-edm.ear" dest="${pm-dir}/pm2/deploy/dist/">
        <patternset>
            <include name="lib/pm-server-conf.jar"/>
        </patternset>
    </unzip>
    <move file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar" tofile="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar"/>
    <zip file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar">
        <zipfileset src="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar">
            <exclude name="log4j.properties"/>
        </zipfileset>
    </zip>
    <zip file="${pm-dir}/pm2/deploy/dist/pm-edm.ear">
        <zipfileset src="${pm-dir}/pm2/deploy/dist/old-pm-edm.ear">
            <exclude name="lib/pm-server-conf.jar"/>
        </zipfileset>
        <zipfileset dir="${pm-dir}/pm2/deploy/dist/lib/" includes="pm-server-conf.jar" fullpath="lib/pm-server-conf.jar"/>
    </zip>
</target>

<!--========================================================================
Builds LEIS
========================================================================-->
<target name="build-proxy" if="build-LEIS">

    <!--copy deploy.properties with the proper jar names and locations-->
    <copy file="LEIS/deploy.properties"        todir="${leis-dir}/proxy/config/build/"    overwrite="true">
        <filterchain>
               <replacetokens>
                    <token key="pmCORE"            value="${pm_CORE_NAME}"/>
                    <token key="pmTRANSFER"        value="${pm_TRANSFER_NAME}"/>
                    <token key="PROXYJARNAME"       value="${PROXY_JAR_NAME}"/>
                    <token key="PROXYCLIENTJARNAME" value="${PROXY_CLIENT_JAR_NAME}"/>
                    <token key="PROXYLIBSDIR"       value="${leis-dir}/JARS/"/>
               </replacetokens>
        </filterchain>
    </copy>

     <ant antfile="build.xml" target="clean" dir="${leis-dir}/proxy" inheritAll="false" />
    <ant antfile="build.xml" target="prod-dist" dir="${leis-dir}/proxy" inheritAll="false">
        <property name="build.name" value="${pm_MAJOR_VERSION}.${BUILD_NUM}"/>
    </ant>

     <ear destfile="${ear-name}" appxml="LEIS/application.xml">
        <metainf dir="${leis-dir}/LEIS/conf/EAR/META-INF" includes="weblogic-application.xml"/>
        <fileset dir="${leis-dir}/JARS/"                   includes="*.jar"/>
        <fileset dir="${leis-dir}/JARS/"                   includes="APP-INF/**" excludes="APP-INF/lib/wlfullclient.jar"/>
    </ear>

    <!-- Place the proxy-client jar in the pm ear-->
    <zip update="true" destfile="${pm-dir}/pm2/deploy/dist/pm-main.ear">
        <zipfileset dir="${leis-dir}/proxy/dist/" includes="${proxy-client-name}" fullpath="APP-INF/lib/${proxy-client-name}"/>
    </zip>

</target>

<target name="build-cpc">
    <copy file="${pm-dir}/pm2/deploy/lib/${pm_TRANSFER_NAME}" todir="${leis-dir}/cpc-web-app/webapp/lib/cpc"/>
    <ant antfile="build.xml" target="build-all-environments" dir="${leis-dir}/cpc-web-app/webapp" inheritAll="false"/>
</target>

<target name="build-all">
    <antcall target="build-LEIS-components"/>
    <antcall target="build-pm"/>
    <antcall target="build-proxy"/>
    <antcall target="build-cpc"/>
</target>    </condition>

<condition property="build-LEIS">
    <equals arg1="True" arg2="${BUILD_LEIS}" />
</condition>


<target name="build-LEIS-components" if="build-LEIS">

    <!--Go through and build the LEIS modules-->
    <ant antfile="build.xml"
         target="clean"
         dir="${leis-dir}/LEIS"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="ejbdoclet"
         dir="${leis-dir}/LEIS/BusinessServices"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="jar"
         dir="${leis-dir}/LEIS"
         inheritAll="false"/>



    <ant antfile="build.xml"
         target="clean"
         dir="${leis-dir}/ETS/trunk/Entitlements"
         inheritAll="false"/>
    <ant antfile="build.xml"
         target="build"
         dir="${leis-dir}/ETS/trunk/Entitlements"
         inheritAll="false"/>


    <mkdir dir="${leis-dir}/JARS/APP-INF/lib/"/>


    <jar jarfile="${leis-dir}/JARS/APP-INF/lib/LEISConfig.jar">
        <fileset dir="LEIS/" includes="datetime.properties"/>
        <fileset dir="LEIS/" includes="log4j.properties"/>
        <manifest>
            <attribute name="Built-By" value="${user.name}"/>
        </manifest>
    </jar>
</target>


<target name="build-pm" if="build-pm">



    <mkdir dir="${pm-dir}/amp2/deploy/propertyoverrides"/>
    <copy todir="${pm-dir}/amp2/deploy/propertyoverrides" overwrite="true">
        <fileset dir="olwAMPconfig/propertyoverrides"/>
    </copy>

    <ant antfile='${pm-dir}/amp2/build/build.xml'          target='clean-build' inheritAll="false"/>

    <!--delete the extra copy of jdo.dtd-->
    <delete file="jdo.dtd" />

    <fileset id="required-amp-client-libs" dir="${pm-dir}/amp2/deploy/lib">
        <include name="*.jar"/>
        <include name="client/*.jar"/>
        <exclude name="*tests.jar"/>
    </fileset>

    <!-- Used to populate value of MANIFEST.MF Class-path attribute. Turns our set of "required" libs
     into a nice space separated string to place in the MANIFEST.MF. Property is used in the "dist"
     task's jar command. -->
    <pathconvert property="client-classpath"
                 refid="required-amp-client-libs"
                 pathsep=" "
                 dirsep="/">
        <map from="${pm-dir}/amp2/deploy/lib/" to=""/>
    </pathconvert>

    <jar update="true" jarfile="${pm-dir}/amp2/deploy/lib/amp-core.jar">
        <manifest>
            <attribute name="Class-Path" value="${client-classpath}"/>
            <attribute name="Main-Class" value="com.retailexp.amp.ui.util.SPPClientStartUp"/>
        </manifest>
    </jar>

    <!-- Creates a file Marimba/BigFix/WhatEver can use to track the version of AMP installed on a machine -->
    <echo message="${AMP_MAJOR_VERSION}.${BUILD_NUM}" file="${pm-dir}/amp2/deploy/lib/version.txt" append="false"/>

    <!-- Remove files we place on classpath from ears, Mantis 10624 -->
    <!-- AMP -->
    <move file="${pm-dir}/amp2/deploy/dist/amp-main.ear" tofile="${pm-dir}/amp2/deploy/dist/old-amp-main.ear"/>
    <unzip src="${pm-dir}/amp2/deploy/dist/old-amp-main.ear" dest="${pm-dir}/amp2/deploy/dist/">
        <patternset>
            <include name="lib/amp-server-conf.jar"/>
        </patternset>
    </unzip>
    <move file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar" tofile="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar"/>
    <zip file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar">
        <zipfileset src="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar">
            <exclude name="log4j.properties"/>
            <exclude name="ehcache-transactional.xml"/>
        </zipfileset>
    </zip>
    <zip file="${pm-dir}/amp2/deploy/dist/amp-main.ear">
        <zipfileset src="${pm-dir}/amp2/deploy/dist/old-amp-main.ear">
            <exclude name="lib/amp-server-conf.jar"/>
        </zipfileset>
        <zipfileset dir="${pm-dir}/amp2/deploy/dist/lib/" includes="amp-server-conf.jar" fullpath="lib/amp-server-conf.jar"/>
    </zip>
    <!-- EDM -->
    <move file="${pm-dir}/amp2/deploy/dist/amp-edm.ear" tofile="${pm-dir}/amp2/deploy/dist/old-amp-edm.ear"/>
    <unzip src="${pm-dir}/amp2/deploy/dist/old-amp-edm.ear" dest="${pm-dir}/amp2/deploy/dist/">
        <patternset>
            <include name="lib/amp-server-conf.jar"/>
        </patternset>
    </unzip>
    <move file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar" tofile="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar"/>
    <zip file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar">
        <zipfileset src="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar">
            <exclude name="log4j.properties"/>
        </zipfileset>
    </zip>
    <zip file="${pm-dir}/amp2/deploy/dist/amp-edm.ear">
        <zipfileset src="${pm-dir}/amp2/deploy/dist/old-amp-edm.ear">
            <exclude name="lib/amp-server-conf.jar"/>
        </zipfileset>
        <zipfileset dir="${pm-dir}/amp2/deploy/dist/lib/" includes="amp-server-conf.jar" fullpath="lib/amp-server-conf.jar"/>
    </zip>
</target>

<!--===============  Builds LEIS   ========================================================================-->
<target name="build-proxy" if="build-LEIS">


    <ant antfile="build.xml" target="clean" dir="${leis-dir}/proxy" inheritAll="false" />
    <ant antfile="build.xml" target="prod-dist" dir="${leis-dir}/proxy" inheritAll="false">
        <property name="build.name" value="${AMP_MAJOR_VERSION}.${BUILD_NUM}"/>
    </ant>

    <!--copy the proxy jar to the LEIS jars library-->
    <copy todir="${leis-dir}/JARS" flatten="true">
        <fileset dir="${leis-dir}/proxy/dist/" >
            <include name="${proxy-name}"/>
        </fileset>
    </copy>

    <!--create a directory to hold the LEIS ear contents-->
    <property name="ear.dir"            value="${leis-dir}/bin"/>
    <property name="ear-name"           value="${ear.dir}/LEIS_AMP.ear"/>
    <mkdir dir="${ear.dir}"/>

    <!--create the ear from the directories contents-->
    <ear destfile="${ear-name}" appxml="LEIS/application.xml">
        <metainf dir="${leis-dir}/LEIS/conf/EAR/META-INF" includes="weblogic-application.xml"/>
        <fileset dir="${leis-dir}/JARS/"                   includes="*.jar"/>
        <fileset dir="${leis-dir}/JARS/"                   includes="APP-INF/**" excludes="APP-INF/lib/wlfullclient.jar"/>
    </ear>

    <!-- Place the proxy-client jar in the amp ear-->
    <zip update="true" destfile="${pm-dir}/amp2/deploy/dist/amp-main.ear">
        <zipfileset dir="${leis-dir}/proxy/dist/" includes="${proxy-client-name}" fullpath="APP-INF/lib/${proxy-client-name}"/>
    </zip>

</target>

<target name="build-cpc">
    <copy file="${pm-dir}/amp2/deploy/lib/${AMP_TRANSFER_NAME}" todir="${leis-dir}/cpc-web-app/webapp/lib/cpc"/>
    <ant antfile="build.xml" target="build-all-environments" dir="${leis-dir}/cpc-web-app/webapp" inheritAll="false"/>
</target>

<!--=========================================    Build AMP and LEIS  --!>

<target name="build-all">
    <antcall target="build-LEIS-components"/>
    <antcall target="build-pm"/>
    <antcall target="build-proxy"/>
    <antcall target="build-cpc"/>
</target>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

染年凉城似染瑾 2024-11-22 06:29:44

只需使用

ant.importBuild 'build.xml'

导入整个 Ant 脚本并逐一替换任务即可开始。稍后尝试将您的项目重构为 gradle 约定,以便您的任务变得过时。

Simply use

ant.importBuild 'build.xml'

to import you whole ant script and replace the tasks one by one to get started. Later try to refactor your project into the gradle conventions so that your tasks become obsolete.

秋风の叶未落 2024-11-22 06:29:44

Ant 和 Gradle 采用一些根本不同的方法来构建 java 项目。与尝试将 Ant 任务转换为 Gradle 不同,您可能会发现更轻松地结合使用项目重构来使用 Gradle 的约定以及一定程度的自定义。

对于你的具体情况,我会采取渐进的方法。从 9 个 ant 目标中选择一个(例如“build-pm”),然后首先专注于构建它。它应该让您清楚地了解将 ant 任务转换为 gradle 需要花费多少精力。

Ant and Gradle take some fundamentally different approaches to building java projects. Instead of trying to convert your Ant tasks to Gradle, you're likely to find it easier to use a combination of re-structuring of your project to use Gradle's conventions with some degree of customization.

In your particular case, I would take an incremental approach. Pick 1 of your 9 ant targets (like "build-pm") and focus on building that first. It should give you a good idea of how much effort you'll have to spend converting your ant tasks to gradle.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文