| Target | Description |
|---|
| setup | show ant settings |
| gen | noop placeholder for code generation |
| compile | compile source code |
| dist | package jar distribution file |
| repo | add jar to local Maven repository |
| clean | delete all non-source files |
| default | calls: clean, dist |
<?xml version="1.0" encoding="UTF-8"?>
<project name="lib" default="default">
<description>
+ ==\_/============J=A=V=A=G=E=N===A=N=T===M=O=D=U=L=E=S================= +
+ \(_)/ +
+ -(_)- Standard Jar Library Core Module +
+ /(_)\ +
+ ======================================================================= +
+ Copyright (c) 2002-2005 Outsource Cafe, Inc. All rights reserved. +
+ ======================================================================= +
+
+ Core module for creating standard Java library (jar) files.
+ It supports compilation, distribution file creation, and clean up.
+ To add unit testing to your build.xml file, import
+ ${jam.home}/utest.xml before this file and redefine the dist or repo target.
+ For example, to run the unit test before installing your jar, do this:
+ <target name="repo" depends="dist, utest, jar.install"/>
+
+ Public targets: setup, gen, compile, dist, repo, clean
+
+ Prerequisite imports: props-global.xml, classpath.xml
+
+ 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="LIB.PRESENT" value="true"></property>
<!-- ===================================================================== -->
<!-- public targets - override as needed -->
<!-- ===================================================================== -->
<target name="setup" depends="init, settings" description="show ant settings"></target>
<target name="gen" depends="init" description="noop placeholder for code generation"></target>
<target name="compile" depends="gen, javac, resources" description="compile source code"></target>
<target name="dist" depends="compile, jar" description="package jar distribution file"></target>
<target name="repo" depends="dist, jar.install" description="add jar 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>
<!-- ===================================================================== -->
<!-- required property defauls - should be predefined elsewere -->
<!-- ===================================================================== -->
<property name="module.name" value="${ant.project.name}"></property>
<property name="module.version" value="?"></property>
<property name="maven.groupId" value="${module.name}"></property>
<!-- ===================================================================== -->
<!-- local properties -->
<!-- ===================================================================== -->
<property name="maven.type" value="jar"></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>
<property name="ear.name" value="${module.name}-${module.version}.ear"></property>
<!-- ===================================================================== -->
<!-- sanity checks -->
<!-- ===================================================================== -->
<fail unless="CLASSPATH.PRESENT" message="classpath.xml must be imported before lib.xml in ${basedir} build for ${module.name}. Regeneration of classpath.xml required when upgrading to JAM 2.1. Type: maven jam"></fail>
<fail unless="PROPS-GLOBAL.PRESENT" message="props-global.xml must be imported before lib.xml in build file."></fail>
<available property="jdk1.3+" classname="java.lang.StrictMath"></available>
<fail unless="jdk1.3+" message="Java versions prior to 1.3 not supported"></fail>
<target name="check">
<echo>DEPRICATED, checks are now in-lined</echo>
</target>
<!-- ===================================================================== -->
<!-- show settings -->
<!-- ===================================================================== -->
<target name="settings">
<echo>
+ ==\_/=======J=A=V=A=G=E=N===A=N=T===M=O=D=U=L=E=S============ +
+ \(_)/ +
+ -(_)- Library Build Settings +
+ /(_)\ +
+ ============================================================= +
module.name/version = ${module.name} / ${module.version}
dist.name = ${dist.name}
java.home/version = ${java.home} / ${ant.java.version}
debug/optimize = ${compiler.debug} / ${compiler.optimize}
appserver.name/ver = ${appserver.name} / ${appserver.version}
ant.home = ${ant.home}
jam.home = ${jam.home}
user.home = ${user.home}
maven.folder = ${maven.folder}
maven.repo = ${maven.repo}
+ =J=A=M=================================J=A=V=A=G=E=N=.=C=O=M= +
</echo>
</target>
<!-- ===================================================================== -->
<!-- init -->
<!-- ===================================================================== -->
<target name="init">
<tstamp></tstamp>
<mkdir dir="${build.classes.dir}"></mkdir>
<mkdir dir="${src.java.dir}"></mkdir>
<mkdir dir="${xdoclet.build.java.dir}"></mkdir>
<mkdir dir="${gen.java.dir}"></mkdir>
</target>
<!-- =================================================================== -->
<!-- compiles the source code -->
<!-- =================================================================== -->
<target name="javac">
<javac destdir="${build.classes.dir}" classpathref="build.classpath" source="${compiler.source}" target="${compiler.target}" debug="${compiler.debug}" deprecation="${compiler.deprecation}" optimize="${compiler.optimize}" compiler="${compiler.type}" excludes="${compiler.excludes}">
<src path="${xdoclet.build.java.dir}"></src>
<src path="${src.java.dir}"></src>
<src path="${gen.java.dir}"></src>
<patternset refid="source.modifications.patternset"></patternset>
</javac>
</target>
<!-- =================================================================== -->
<!-- resources: copy resources to build/classes -->
<!-- =================================================================== -->
<!-- the 'resources' target, found in classpath.xml, is generated from the POM.
The default project.xml entry is:
<build>
<sourceDirectory>src/java</sourceDirectory>
<resources>
<resource>
<directory>src/resources</directory>
</resource>
<resource>
<directory>src/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src-gen/resources</directory>
</resource>
<resource>
<directory>src-gen/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>target/xdoclet/resources</directory>
</resource>
<resource>
<directory>target/xdoclet/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>target/xdoclet/META-INF</directory>
<targetPath>META-INF</targetPath>
</resource>
</resources>
</build>
-->
<!-- =================================================================== -->
<!-- creates jar archive distribution file -->
<!-- =================================================================== -->
<target name="jar">
<delete file="{dist.file}"></delete>
<mkdir dir="${dist.dir}"></mkdir>
<jar jarfile="${dist.file}">
<fileset dir="${build.classes.dir}" includes="**"></fileset>
</jar>
</target>
<!-- =================================================================== -->
<!-- supports ear target - find and copy application.xml or fail -->
<!-- =================================================================== -->
<target name="appxml">
<property name="target.modules" value="<module><java>${dist.name}</web></module>"></property>
<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.modules}"></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.modules}"></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-filter"></fail>
</target>
<!-- =================================================================== -->
<!-- optional - ear packaging -->
<!-- =================================================================== -->
<target name="ear" depends="appxml">
<delete file="${dist.dir}/${ear.name}"></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.dir}/${ear.name}" appxml="${build.metainf.dir}/application.xml">
<fileset dir="${dist.dir}" includes="*.*"></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}"></delete>
</target>
<target name="clean.dist">
<delete dir="${dist.dir}"></delete>
</target>
<!-- =================================================================== -->
<!-- installs jar in Maven repository -->
<!-- =================================================================== -->
<target name="jar.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>