Strategies for deploying an exploded ear
I have a build process that开发者_开发百科 creates an ear in a fairly complicated manner (multiple EJB jars, a couple of wars, a couple of sars (which are JBoss specific). The ant process for piecing this together is somewhat complex.
What is the best strategy to not recreate the creation logic of the ejb creation in ANT but still be able to deploy exploded to the application server or in an ear for QA and production.
Although I'm concerned about JBoss, the question is really relevant to any application server that supports exploded ear deployment, and is really more about ANT, how to avoid two different targets that recreated the logic of creating a zip file vs copying to a directory.
I've found that what works best for us, is to create the ZIP/EAR/WAR/JAR contents in exploded form in the file system, and then as the final step zip/ear/war/jar it up to a file.
This allows us to have post processing steps which only knows of files and not zip-file entries, which is usually much simpler. If you work with an exploded deployment and a server which picks up changed files in the exploded deployment, you can simply use rsync to update only those files actually changed in the server deployment.
You would then have the building in one target, and packing in another, making it easy to do both.
See Alexander Pogrebnyak's answer in regards to how to handle manifests using this solution.
This is in reply to your comment about manifest.
You should use <manifest>
task (here is the link) to control manifest creation.
Here is the excerpt from my build file to supply manifest.
<copy toDir="${stage.dir}" flatten="true">
<fileset dir="${resources.src.dir}">
<include name="META-INF/MANIFEST.MF"/>
</fileset>
</copy>
<manifest
file="${stage.dir}/MANIFEST.MF"
mode="update"
>
<attribute name="Built-By" value="${builder.name}" />
</manifest>
<jar destfile="${project.jar.file}"
basedir="${classes.dir}"
manifest="${stage.dir}/MANIFEST.MF"
duplicate="fail"
whenmanifestonly="fail"
/>
Pay attention to <manifest>
task mode
attribute. You always want to set it to update
, otherwise <jar>
task will always be running, as manifest will always be out-of-date.
An .ear file is a .zip file. To deploy an exploded version just unzip the contents into a folder named *.ear.
精彩评论