Partially deploy a web app in EAServer by using jagant

My boss doesn’t want to deploy the whole web application as a jar file to target server. Instead, he likes to copy the single files into the target folder. Fortunately I configured a jagant build file to  do all of those manual operations for me automatically. Here are some basic ideas:

  1. Backup Target – Export the web app from target server to a single jar file: jar_T.

            <delete file=”${bak}/aglc_secure.jar”  />
    <jag_export jagjar=”true” entity=”WebApp:aglc_secure” dir=”${bak}”/>

  2. Export Source – Export the web app from source server to a single jar file: jar_S.
  3. UnJar all the changed files from jar_S to a temp folder.

            <unjar src=”${new}/aglc_secure.jar” dest=”${jsp}”>
    <include name=”**/*.jsp”/>
    <exclude name=”**/*.LCK”/>
    <exclude name=”**/*.scc”/>

  4. Change last modified time of all the files in temp folder.

    <format property=”new.file.modified.time” pattern=”MM/dd/yyyy hh:mm aa” offset=”1″ unit=”minute” />

    <echo message=”Changing file last_modified time to ${new.file.modified.time}……”/>
    <touch datetime=”${new.file.modified.time}” >
    <fileset dir=”${jsp}” />

  5. Jar update the jar_S file, then deploy it to target server.

             <jar destfile=”${new}/aglc_secure.jar”     basedir=”${jsp}” update=”true”/>

    <!– actual deploy  –>
    <jag_deploy type=”jagjar” jagjartype=”WebApplication” file=”${new}/aglc_secure.jar” />
    <jag_refresh entity=”WebApp:aglc_secure” />

The purpose of step 4 is, all the files in war_T are marked as the exporting time, which means it’s NOW, and is always newer than the files in temp folder. This will cause the jar update command won’t succeed even with the ‘update=true’ property.

I had to set new time to one minute in the future, second doesn’t work because the file modified time interval is one minute.

Thanks God, ant has a secret file task called ‘Touch’, which can modify file’s last modified time. This strange name makes sense but it helps a lot.

Stupid me was doing unjar the whole file, copy change files, then create a new jar file, because I couldn’t make jar update work until I found this surprising TOUCH this morning.

Another good thing about this is, we don’t need access to the folder of either target or source server, the password of jagadmin is good enough.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s