Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant Ear Update Without Full Exploding Ear

Tags:

java

ant

ear

I'm using ant 1.8.2 and I have a large Ear file.

Slight changes to the ear are needed, depending on user selection during install.

At the end of the install process, I run an ant script which updates the ear based on the user's selections. These files are only to be included in the ear, if the user has related licensing... so the update is necessary.

Currently I'm exploding the whole ear, adding the necessary files, then making the updated ear.

I'm hoping to find a way in which I can remove and/or add files without having to go through the whole unzip/update/zip process.

like image 767
James Oravec Avatar asked Aug 21 '12 16:08

James Oravec


2 Answers

The ear task has an update attribute, which you can set to true.

This way files will be added to the existing zipfile, instead of creating a new one.

like image 171
oers Avatar answered Sep 26 '22 20:09

oers


@oers thanks for the suggestion, the following is the POC I used to add a file to an ear and replace the application.xml file.

<property name="ear.file1"  value="file1.ear"/>
<property name="ear.file2"  value="file2.ear"/>
<property name="text.file1" value="1.txt"/>
<property name="text.file2" value="2.txt"/>
<property name="xml.application1"   value="application.xml"/>
<property name="xml.application2"   value="application2.xml"/>

<target name="clean">
    <delete file="${ear.file1}"/>
    <delete file="${ear.file2}"/>
</target>

<target name="run">
    <!-- simple ear -->
    <ear earfile="${ear.file1}" appxml="${xml.application1}">
        <fileset dir="." includes="${text.file1}"/>
    </ear>  

    <!-- simple ear that will be updated -->
    <ear earfile="${ear.file2}" appxml="${xml.application1}">
        <fileset dir="." includes="${text.file1}"/>
    </ear>  
    <!-- ear update, both application.xml file and add another file. -->
    <ear earfile="${ear.file2}" appxml="${xml.application2}" update="true">
        <fileset dir="." includes="${text.file2}"/>
    </ear>  

</target>

<target name="main" depends="clean,run"/>

like image 38
James Oravec Avatar answered Sep 24 '22 20:09

James Oravec