【问题标题】:Ant Nested Update蚂蚁嵌套更新
【发布时间】:2012-08-22 15:50:32
【问题描述】:

这是与我昨天提出的问题相关的后续问题: Ant Ear Update Without Full Exploding Ear

我正在使用 Ant 1.8.2 并且能够使用我在上面提供的链接中创建的示例来更新文件。

我的 ear 文件中有一个 war 文件,我希望看看是否有办法进行嵌套更新(例如,更新 ear 中的 war 文件)。

我的另一个选择是提取战争,更新战争,然后用更新的战争更新耳朵。如果有办法进行嵌套更新,我认为这会节省我的时间,因为我的 war 文件很大。

【问题讨论】:

    标签: java ant jboss war ear


    【解决方案1】:

    以下是我的替代方法 POC,以防有人感兴趣。如果我们找不到“嵌套”更新,我会使用它。

    <property name="ear.file1"          value="file1.ear"/>
    <property name="war.file1"          value="war1.war"/>
    <property name="war.file"           value="war.war"/>
    <property name="war.file.backup"    value="warBk.war"/>
    <property name="text.file1"         value="1.txt"/>
    <property name="text.file2"         value="2.txt"/>
    <property name="xml.application1"   value="application.xml"/>
    
    <target name="clean">
        <delete file="${ear.file1}"/>
        <delete file="${war.file}"/>
        <delete file="${war.file.backup}"/>
    </target>
    
    <target name="run">
    
        <!-- Our war file contains 1.txt, allows us add 2.txt and verify updates properly -->
        <copy file="${war.file1}" tofile="${war.file}"/>
    
        <!-- simple ear that will be updated -->
        <ear earfile="${ear.file1}" appxml="${xml.application1}">
            <fileset dir="." includes="${text.file1}"/>
            <fileset dir="." includes="${war.file}"/>
        </ear>  
    
        <!-- Backup war, for comparision purposes -->
        <move file="${war.file}" tofile="${war.file.backup}" overwrite="true" />
    
        <!-- Extact the war we just added -->
        <unzip dest="." src="${ear.file1}" overwrite="true" >
            <patternset>
                <include name="${war.file}" />
            </patternset>
        </unzip>
    
        <!-- Update the war by adding a file -->
        <war destfile="${war.file}" update="true">
            <fileset dir="." includes="${text.file2}"/>
        </war>
    
        <!-- Update the ear with our updated war -->
        <ear earfile="${ear.file1}" appxml="${xml.application1}" update="true">
            <fileset dir="." includes="${war.file}"/>
        </ear>  
    </target>
    
    <target name="main" depends="clean,run"/>
    

    【讨论】:

      猜你喜欢
      • 2012-08-02
      • 1970-01-01
      • 1970-01-01
      • 2015-03-22
      • 1970-01-01
      • 2020-12-27
      • 2010-09-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多