EAR Core Module

Public Targets

TargetDescription
setupshow ant settings
distpackage ear distribution file
repoadd ear to local Maven repository
cleandelete all non-source files
defaultcalls: clean, dist

Source: ear.xml

				<?xml version="1.0" encoding="UTF-8"?>
<project name="ear" default="default">
	<description>
  + ==\_/============J=A=V=A=G=E=N===A=N=T===M=O=D=U=L=E=S================= +
  +  \(_)/                                                                  +
  +  -(_)-                    EAR Core Module                               +
  +  /(_)\                                                                  +
  + ======================================================================= +
  +    Copyright (c) 2002-2005 Outsource Cafe, Inc.  All rights reserved.   +
  + ======================================================================= +
  +
  + Packages EAR distribution file.  Dependencies should be in the repository. 
  +
  + Targets: setup, dist, repo, clean
  +
  + Prerequisites: 
  +  import: props-maven.xml, props-global.xml, classpath.xml
  +  generate: application.xml (call: maven javagen:appxml)
  +
  + developer: RichardEasterling@OutsourceCafe.com
  + ======================================================================= +
  + Licensed under the Apache License, Version 2.0 (the "License");
  + you may not use this file except in compliance with the License.
  + You may obtain a copy of the License at
  +
  +   http://www.apache.org/licenses/LICENSE-2.0
  +
  + Unless required by applicable law or agreed to in writing, software
  + distributed under the License is distributed on an "AS IS" BASIS,
  + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + See the License for the specific language governing permissions and
  + limitations under the License.
  + =J=A=M===========================================J=A=V=A=G=E=N=.=C=O=M= +
	</description>
	<property name="EAR.PRESENT" value="true"></property>
	<!-- ===================================================================== -->
	<!-- public targets - override as needed -->
	<!-- ===================================================================== -->
	<target name="setup" depends="settings" description="show ant settings"></target>
	<target name="dist" depends="appxml, ear" description="package ear distribution file"></target>
	<target name="repo" depends="dist, ear.install" description="add ear to local Maven repository"></target>
	<target name="clean" depends="clean.build, clean.dist" description="delete all non-source files"></target>
	<target name="default" depends="clean, dist" description="calls: clean, dist"></target>
	<!-- ===================================================================== -->
	<!-- local properties -->
	<!-- ===================================================================== -->
	<property name="maven.type" value="ear"></property>
	<property name="maven.folder" value="${maven.groupId}/${maven.type}s"></property>
	<property name="dist.name" value="${module.name}-${module.version}.${maven.type}"></property>
	<property name="dist.file" location="${dist.dir}/${dist.name}"></property>
	<property name="pom.file.name" value="${module.name}-${module.version}.pom"></property>
	<property name="pom.file" value="${basedir}/project.xml"></property>
	<!-- remove @TARGET-MODULE@ tag if present in application.xml -->
	<property name="target.module" value=""></property>
	<!-- ===================================================================== -->
	<!-- sanity checks -->
	<!-- ===================================================================== -->
	<fail unless="PROPS-GLOBAL.PRESENT" message="props-global.xml must be imported before ear.xml in build file."></fail>
	<!-- ===================================================================== -->
	<!-- show settings -->
	<!-- ===================================================================== -->
	<target name="settings">
		<echo>
+ ==\_/=======J=A=V=A=G=E=N===A=N=T===M=O=D=U=L=E=S============ +
+  \(_)/                                                        +
+  -(_)-               Ear Build Settings                       +
+  /(_)\                                                        +
+ ============================================================= +
module.name          = ${module.name}
module.version       = ${module.version}
dist.name            = ${dist.name}
compiler.debug       = ${compiler.debug}
java.home            = ${java.home}
ant.home             = ${ant.home}
maven.home           = ${maven.home}
maven.repo           = ${maven.repo}
maven.folder         = ${maven.folder}
jam.home             = ${jam.home}
+ =J=A=M=================================J=A=V=A=G=E=N=.=C=O=M= +
    </echo>
	</target>
	<!-- =================================================================== -->
	<!-- find the application.xml or die, 'src' instance takes priority -->
	<!-- =================================================================== -->
	<target name="appxml">
		<condition property="duplicate.appxmls">
			<and>
				<available file="${gen.metainf.dir}/application.xml"></available>
				<available file="${src.metainf.dir}/application.xml"></available>
			</and>
		</condition>
		<fail if="duplicate.appxmls" message="ERROR: Two application.xml files found in ${gen.metainf.dir} and ${src.metainf.dir}. Please remove one."></fail>
		<mkdir dir="${build.metainf.dir}"></mkdir>
		<copy file="${gen.metainf.dir}/application.xml" todir="${build.metainf.dir}" failonerror="false" overwrite="true">
			<filterset>
				<filter token="TARGET-MODULE" value="${target.module}"></filter>
			</filterset>
		</copy>
		<copy file="${src.metainf.dir}/application.xml" todir="${build.metainf.dir}" failonerror="false" overwrite="true">
			<filterset>
				<filter token="TARGET-MODULE" value="${target.module}"></filter>
			</filterset>
		</copy>
		<available property="appxml.found" file="${build.metainf.dir}/application.xml"></available>
		<fail unless="appxml.found" message="ERROR: application.xml NOT FOUND in ${src.metainf.dir} or ${gen.metainf.dir}, run: maven jam:appxml"></fail>
	</target>
	<!-- =================================================================== -->
	<!-- package ear -->
	<!-- =================================================================== -->
	<target name="ear">
		<delete file="${dist.file}"></delete>
		<mkdir dir="${dist.dir}/${temp.folder}"></mkdir>
		<copy todir="${dist.dir}/${temp.folder}">
			<fileset refid="ear.lib.fileset"></fileset>
			<mapper type="flatten"></mapper>
		</copy>
		<ear destfile="${dist.file}" appxml="${build.metainf.dir}/application.xml">
			<fileset dir="${dist.dir}" includes="*.war,*.jar"></fileset>
			<fileset dir="${dist.dir}/${temp.folder}"></fileset>
		</ear>
		<delete dir="${dist.dir}/${temp.folder}" failonerror="false"></delete>
	</target>
	<!-- =================================================================== -->
	<!-- clean targets: build and distribution cleanup -->
	<!-- =================================================================== -->
	<target name="clean.build">
		<delete dir="${build.dir}" failonerror="false"></delete>
	</target>
	<target name="clean.dist" depends="">
		<delete dir="${dist.dir}" failonerror="false"></delete>
	</target>
	<!-- =================================================================== -->
	<!-- installs ear in Maven repository -->
	<!-- =================================================================== -->
	<target name="ear.install">
		<mkdir dir="${maven.repo}/${maven.folder}"></mkdir>
		<copy file="${dist.file}" todir="${maven.repo}/${maven.folder}"></copy>
		<checksum fileext=".md5" file="${maven.repo}/${maven.folder}/${dist.name}" forceoverwrite="true"></checksum>
		<mkdir dir="${maven.repo}/${maven.groupId}/poms"></mkdir>
		<copy file="${pom.file}" tofile="${maven.repo}/${maven.groupId}/poms/${pom.file.name}"></copy>
	</target>
</project>