4

My JSF Project is deployed as an EAR file. It includes some war files also. I need an exploded version of the EAR (including exploded inner WARs).

Is there any tool to do it?

Tony
  • 10,088
  • 20
  • 85
  • 139
  • If its really your project you should have the source? In any case, you can extract the EAR with the ZIP command, same thing with the WAR files. ***Or***, are you asking how to deploy the EAR as an exploded archive to the app server? – Perception Apr 16 '12 at 13:25
  • Yes, it is my source. I wondering if there is an automated tool to do this, since there are a lot of wars in the ear. I think that the only thing that I have to do to deploy the EAR as an exploded archive is to copy the contents of the ear in a folder named ".ear", right? – Tony Apr 16 '12 at 13:25

2 Answers2

5

Programmatically, or manually? EAR and WAR files, like JAR files, are really just ZIP files with a known internal file/folder structure. That means you can extract EARs and WARs like any other ZIP file, with code or with a desktop application.


Command line tool for windows would be great.

Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
  • I wondering if there is an automated tool to do this, since there are a lot of wars in the ear. – Tony Apr 16 '12 at 13:28
  • Not programatically, I mean, I dont want to explode the EAR from code. Command line tool for windows would be great. – Tony Apr 16 '12 at 13:31
3

Matt's answer was helpful, but sometimes it's nice to have it written out for you.

Here is a shell script that I wrote to solve this problem that I actually ran in Cygwin but would likely work in Linux also. It will unzip and wars, ears, or jars and keep unzipping them until recursively until none are left. You may want to then use "diff -r ear1.ear-contents ear2.ear-contents" on the resulting directories to compare two ear files.

#!/bin/sh

rm -rf ${1}-contents
mkdir ${1}-contents

echo "Unpacking ${1} to ${1}-contents"
unzip -d ${1}-contents ${1}

cd ${1}-contents

FILES_TO_PROCESS=`find . -type f \( -name "*.ear" -or -name "*.war" -or -name "*.jar" \)`

until [ "$FILES_TO_PROCESS" == "" ] ; do

    for myFile in $FILES_TO_PROCESS ; do

        mkdir ${myFile}-contents
        echo "Unpacking ${myFile} to ${myFile}-contents"
        unzip -d ${myFile}-contents ${myFile}
        rm $myFile

    done


    FILES_TO_PROCESS=`find . -type f \( -name "*.ear" -or -name "*.war" -or -name "*.jar" \)`
    echo "recursing to process files: $FILES_TO_PROCESS"
done
Jared
  • 1,887
  • 3
  • 20
  • 45