根據Eclipse SVN changelog使用ANT自動打增量包

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   io   os   使用   ar   

1、擷取changeLog

  用eclipseSVN的外掛程式功能查看history。

  

  將記錄檔匯出到本地檔案svn_change.log,格式如下

  

r63 | xiaodaoshi | 2014-08-08 18:01:36 CSTChanged paths:    M /root/Testproject/ANT_DEMO/demo/src/com/csdn/common/util/StringUtil.java    M /root/Testproject/ANT_DEMO/demo/src/com/csdn/service/First.java    A /root/Testproject/ANT_DEMO/demo/src/com/csdn/service/Second.java    M /root/Testproject/ANT_DEMO/demo/src/com/csdn/service/Third.java    M /root/Testproject/ANT_DEMO/demo/webapps/demo/welcome/welcome.jsp    M /root/Testproject/ANT_DEMO/demo/webapps/demo/images/welcome.png<description>測試</description>xds9527----------------------------------------------------------------------------

2、ANT指令碼的編寫,基本原理是讀取changeLog.txt,首先過濾將注釋,提交人..等等不需要的資訊過濾掉。匯入到新檔案patch.log。在讀取此檔案根據Regex處理沒效的目錄,在替換成真實編譯後的classes目錄。將.java替換成*.class尾碼。*是為了萬用字元。匹配內部類。如何根據檔案複製到新目錄下。在根據此打包。就基本完成功能了。

  無效資訊過濾後檔案內容

webapps/demo/WEB-INF/classes/com/csdn/common/util/StringUtil*.classwebapps/demo/WEB-INF/classes/com/csdn/service/First*.classwebapps/demo/WEB-INF/classes/com/csdn/service/Second*.classwebapps/demo/WEB-INF/classes/com/csdn/service/Third*.classwebapps/demo/welcome/welcome.jspwebapps/demo/images/welcome.png

下面是完整的ANT指令碼

<?xml version="1.0" encoding="UTF-8"?><project name="project" default="patch_without_compile">    <!-- TLBADX 項目 -->    <property name="project.name" value="demo" />    <tstamp><format property="date.today" pattern="yyyyMMdd" /></tstamp>    <!-- svn提交change日誌 -->    <property name="change.log" value="./changeLog.txt" />    <!-- 補丁包所在目錄 -->    <property name="build.dir" value="./release" />    <!-- 讀取svn日誌提取出新增和修改檔案 擷取補丁包包含的檔案 -->    <property name="patch.includesfile" value="${build.dir}/patchfiles.txt" />    <!-- 補丁包名稱 -->    <property name="dest.zip" value="${project.name}_${date.today}_patch.zip" />    <!-- - - - - - - - - - target:從svn日誌中,取出checkin檔案 - - - - - - - - - -->    <target name="patchfile" depends="init" description="處理 svn_changge 日誌 ">        <!-- 去掉 SVN日誌中的注釋,只保留Added和Modified記錄 -->        <concat destfile="${patch.includesfile}" append="false" force="true">            <fileset file="${change.log}" />            <filterchain>                <containsregex byline="true" pattern="^([\s]+)(?:A|M)([\s]+)(.+)$" replace="\3" />            </filterchain>        </concat>        <!-- 將src目錄替換為classes目錄 主要針對提交的代碼 -->        <replaceregexp file="${patch.includesfile}" byline="true">            <!-- (?:X) X作為非擷取的群組 相當於java的group概念 提取出代碼的相對路徑 -->            <regexp pattern="^/.+/(?:src)/(.+)\..+$" />            <substitution expression="webapps/toolbar/WEB-INF/classes/\1*.class" />        </replaceregexp>        <!-- 替換掉WebRoot/前面的路徑 主要針對提交.js .css 等圖片分頁檔 -->        <replaceregexp file="${patch.includesfile}" byline="true">            <!-- (?=X) 從句子前面讀取 如果X前面為空白直接略過。 前面不為空白的執行替換操作 -->            <regexp pattern="^/.+/(?=webapps/)" />            <substitution expression="" />        </replaceregexp>    </target>    <!-- - - - - - - - - - target:package - - - - - - - - - -->    <target name="package" description="補丁包">        <delete dir="${build.dir}/webapps" />        <copy todir="${build.dir}" overwrite="true">            <fileset dir="." includesfile="${patch.includesfile}" />        </copy>        <delete file="${build.dir}/${dest.zip}" />        <zip destfile="${build.dir}/${dest.zip}" compress="true">            <zipfileset prefix="webapps" dir="${build.dir}/webapps">                <include name="**" />            </zipfileset>        </zip>    </target>    <!-- - - - - - - - - - target:release without compile - - - - - - - - - -->    <target name="patch_without_compile" depends="patchfile, package" description="--> release">        <echo>補丁包打包結束</echo>    </target>        <!-- - - - - - - - - -target: init - - - - - - - - - -->    <target name="init" depends="clean">        <mkdir dir="${build.dir}"/>    </target>    <!-- - - - - - - - - -target: clean - - - - - - - - - -->    <target name="clean">        <delete dir="${build.dir}" />    </target>    </project>

  這樣的話擷取版本changeLog.txt,執行ANT指令碼。在release目錄下就會產生補丁包了。

根據Eclipse SVN changelog使用ANT自動打增量包

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.