blob: be33c3f82f7b52e2bff0de769a0e804e431bfb63 [file] [log] [blame]
<!-- This file is an ANT build script. ANT is a Java based build tool. -->
<!-- It is availale from http://jakarta.apache.org/ant/ -->
<!-- ================================================================= -->
<!-- NOTE: all directories are relative to jakarta-log4j/ -->
<!-- the parent of build/ -->
<!-- ================================================================= -->
<project name="log4j" default="build" basedir="." >
<!-- The build.properties file defines the parth to local jar files -->
<property file="build.properties"/>
<property name="version" value="1.3alpha"/>
<!-- The base directory relative to which most targets are built -->
<property name="base" value="."/>
<!-- The directory where source files are stored. -->
<property name="java.source.dir" value="src/java/"/>
<!-- The directory where the package-list file is found, ./ or -->
<!-- build/ -->
<property name="packaging.dir" value="build"/>
<!-- Destination for compiled files -->
<property name="javac.dest" value="dist/classes"/>
<!-- Destination for generated jar files -->
<property name="jar.dest" value="${basedir}"/>
<!-- The jar file that the jar task will generate -->
<property name="log4j.jar" value="log4j-${version}.jar"/>
<!-- The jar file that the jar-chainsaw task will generate -->
<property name="log4j-chainsaw.jar" value="log4j-chainsaw-${version}.jar"/>
<!-- The jar file that the jar-lf5 task will generate -->
<property name="log4j-lf5.jar" value="log4j-lf5-${version}.jar"/>
<!-- Destination for documentation files -->
<property name="docs.dest" value="./docs"/>
<!-- Source directory for xml docs -->
<property name="xdocs.src" value="./src/xdocs"/>
<!-- Destination for javadoc generated files -->
<property name="javadoc.dest" value="docs/api"/>
<!-- Icons source directory. -->
<property name="icons.source" value="icons"/>
<!-- The stem where most log4j source code is located. -->
<property name="stem" value="org/apache/log4j"/>
<!-- Some targets needs a more precise stem. -->
<property name="BSTEM" value="${java.source.dir}/${stem}"/>
<!-- Original manifest.mf file before filtering. -->
<property name="manifest.src" value="build/manifest.mf"/>
<!-- Directory where release images go. -->
<property name="dist.images" value="dist/images"/>
<!-- Directory for temporary files. -->
<property name="dist.tmp" value="dist/tmp"/>
<!-- Construct compile classpath -->
<path id="compile.classpath">
<pathelement location="${javac.dest}"/>
<pathelement location="${javamail.jar}"/>
<pathelement location="${activation.jar}"/>
<pathelement location="${jaxp.jaxp.jar}"/>
<pathelement location="${jaxp.parser.jar}"/>
<pathelement location="${jms.jar}"/>
<pathelement location="${jmx.jar}"/>
<pathelement location="${jmx-extra.jar}"/>
<pathelement location="${avalon-framework.jar}"/>
</path>
<!-- Construct classpath for building the html pages-->
<path id="site2.classpath">
<fileset dir="${jakarta-site2}/lib">
<include name="*.jar"/>
</fileset>
</path>
<!-- ================================================================= -->
<!-- Default target -->
<!-- ================================================================= -->
<target name="usage">
<echo>
These are the targets supported by this ANT build scpript:
build - compile all project files, if a certain library is missing,
then the compilation of its dependents are skipped.
javadoc - build project javadoc files
jar - build log4j-core and log4j jar files
dist - will create a complete distribution in dist/
</echo>
</target>
<target name="jaxpCheck">
<available classname="javax.xml.parsers.DocumentBuilderFactory"
property="jaxp-present"/>
</target>
<target name="jaxp" depends="jaxpCheck" if="jaxp-present">
<echo message="JAXP present."/>
</target>
<target name="avalonFrameworkCheck">
<available classname="org.apache.avalon.framework.logger.Logger"
property="avalonFramework-present">
<classpath>
<pathelement location="${avalon-framework.jar}"/>
</classpath>
</available>
</target>
<target name="avalonFramework" depends="avalonFrameworkCheck" if="avalonFramework-present">
<echo message="Avalon Framework is present."/>
</target>
<target name="jmxCheck">
<available classname="javax.management.MBeanInfo" property="jmx-present">
<classpath>
<pathelement location="${jmx.jar}"/>
</classpath>
</available>
</target>
<target name="jmx" depends="jmxCheck" if="jmx-present">
<echo message="JMX is present."/>
</target>
<target name="jmsCheck">
<available classname="javax.jms.Message" property="jms-present">
<classpath>
<pathelement location="${jms.jar}"/>
</classpath>
</available>
</target>
<target name="jms" depends="jmsCheck" if="jms-present">
<echo message="JMS is present."/>
</target>
<target name="jndiCheck">
<available classname="javax.naming.Context" property="jndi-present"/>
</target>
<target name="jndi" depends="jndiCheck" if="jndi-present">
<echo message="JNDI is present."/>
</target>
<target name="javamailCheck">
<available classname="javax.mail.Message" property="javamail-present">
<classpath>
<pathelement location="${javamail.jar}"/>
</classpath>
</available>
</target>
<target name="javamail" depends="javamailCheck" if="javamail-present">
<echo message="JAVAMAIL is present."/>
</target>
<!-- ================================================================= -->
<!-- Initialize variables -->
<!-- NOTE: all directories are relative to jakarta-log4j/ -->
<!-- ================================================================= -->
<target name="init">
<tstamp />
</target>
<target name="build" description="Compile all log4j components."
depends="init, build.core, build.chainsaw, build.examples, build.xml,
build.javamail, build.jms, build.jmx, build.avalonFramework"/>
<target name="build.core" depends="init">
<mkdir dir="${javac.dest}" />
<javac srcdir="${java.source.dir}"
destdir="${javac.dest}"
includes="${stem}/**/*.java, ${stem}/xml/XMLLayout.java,"
excludes="misc/*, **/UnitTest*.java,
**/StressCategory.java,
**/doc-files/*,
${stem}/xml/**,
${stem}/test/serialization/**,
${stem}/net/SMTPAppender.java,
${stem}/net/JMS*.java,
${stem}/jmx/*.java,
${stem}/chainsaw/*.java,
${stem}/varia/Log4JAvalonLogger.java,
${stem}/or/jms/*.java"
deprecation="${deprecation}"
debug="on">
<classpath refid="compile.classpath"/>
</javac>
<copy todir="${javac.dest}">
<fileset dir="${java.source.dir}"
includes="${stem}/lf5/**/*.properties"/>
<fileset dir="${java.source.dir}"
includes="${stem}/lf5/viewer/images/*"/>
</copy>
</target>
<target name="build.examples" depends="build.core">
<mkdir dir="${javac.dest}" />
<javac srcdir="${basedir}"
destdir="${javac.dest}"
includes="examples/**/*.java"
excludes="misc/*, examples/jmx/*.java"
deprecation="${deprecation}"
debug="on">
<classpath refid="compile.classpath"/>
</javac>
<rmic base="${javac.dest}" classname="examples.NumberCruncherServer" />
<copy todir="${javac.dest}">
<fileset dir="." includes="examples/lf5/**/*.properties"/>
<fileset dir="." includes="examples/lf5/**/*.xml"/>
</copy>
</target>
<target name="build.xml" depends="init, jaxp" if="jaxp-present">
<javac srcdir="${java.source.dir}"
destdir="${javac.dest}"
includes="${stem}/xml/**/*.java"
excludes="${stem}/xml/examples/doc-files/**.java,
${stem}/xml/Transform.java"
deprecation="${deprecation}">
<classpath refid="compile.classpath"/>
</javac>
<copy file="${BSTEM}/xml/log4j.dtd"
tofile="${javac.dest}/${stem}/xml/log4j.dtd" />
</target>
<target name="build.avalonFramework" depends="init, avalonFramework" if="avalonFramework-present">
<javac srcdir="${java.source.dir}"
destdir="${javac.dest}"
deprecation="${deprecation}"
includes="${stem}/varia/Log4JAvalonLogger.java">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="build.javamail" depends="init, javamail"
if="javamail-present">
<javac srcdir="${java.source.dir}"
destdir="${javac.dest}"
deprecation="${deprecation}"
includes="${stem}/net/SMTPAppender.java">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="build.jms" depends="init, jms, jndi" if="jms-present">
<javac deprecation="${deprecation}"
srcdir="${java.source.dir}"
destdir="${javac.dest}"
includes="${stem}/net/JMS*.java">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="build.jmx" depends="init, jmx, jndi" if="jmx-present">
<javac deprecation="${deprecation}"
srcdir="${java.source.dir}"
destdir="${javac.dest}"
includes="${stem}/jmx/*.java"
excludes="${stem}/jmx/T.java">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="build.chainsaw" depends="init, chainsawCheck, build.core" if="chainsaw-libraries-present">
<javac deprecation="${deprecation}"
srcdir="${java.source.dir}"
destdir="${javac.dest}"
includes="${stem}/chainsaw/**/*.java"
excludes="">
<classpath refid="compile.classpath"/>
<classpath path="${regexp.oro.jar}"/>
</javac>
</target>
<!-- ================================================================= -->
<!-- Remove all generated (compiled) class files. -->
<!-- ================================================================= -->
<target name="clean" depends="init" description="Delete all compiled files.">
<delete dir="${javac.dest}/" />
</target>
<!-- ================================================================= -->
<!-- Define the set of files current styled -->
<!-- ================================================================= -->
<fileset dir="${java.source.dir}" id="styled_files">
<include name="**/plugins/*.java"/>
<include name="**/chainsaw/*.java"/>
</fileset>
<!-- ================================================================= -->
<!-- Define the set of files current styled -->
<!-- ================================================================= -->
<fileset dir="${java.source.dir}" id="checkstyled_files">
<include name="org/apache/log4j/*.java"/>
<include name="org/apache/log4j/spi/*.java"/>
<include name="**/plugins/*.java"/>
<include name="**/chainsaw/*.java"/>
</fileset>
<!-- ================================================================= -->
<!-- Runs jalopy. Available from http://jalopy.sourceforge.net -->
<!-- ================================================================= -->
<target name="runJalopy">
<path id="jalopy.path">
<fileset dir="${jalopy.lib}">
<include name="*.jar" />
</fileset>
</path>
<taskdef name="jalopy"
classname="de.hunsicker.jalopy.plugin.ant.AntPlugin"
classpathref="jalopy.path" />
<jalopy backup="true"
classpathref="compile.classpath"
convention="src/jalopy/log4j-coding-convention.xml">
<fileset refid="styled_files"/>
</jalopy>
</target>
<!-- ================================================================= -->
<!-- Runs jalopy preferences editor. -->
<!-- ================================================================= -->
<target name="editJalopyPreferences">
<path id="jalopy.path">
<fileset dir="${jalopy.lib}">
<include name="*.jar" />
</fileset>
</path>
<java classname="de.hunsicker.jalopy.swing.SettingsDialog"
classpathref="jalopy.path"
fork="true" />
</target>
<!-- ================================================================= -->
<!-- Runs checkstyle. Available from http://checkstyle.sf.net -->
<!-- ================================================================= -->
<target name="checkstyle" depends="init">
<taskdef resource="checkstyletask.properties"
classpath="${checkstyle.jar}"/>
<!-- by default checkstyle supports the Sun coding standard. -->
<checkstyle config="src/sun_checks.xml">
<fileset refid="checkstyled_files"/>
<!-- allow public in interfaces even if redundant -->
<property key="checkstyle.ignore.public.in.interface" value="true" />
<!-- do not check javadocs -->
<property key="checkstyle.javadoc.scope" value="nothing" />
<!-- allow for lines of 100 chars. These long lines will be
weeded out by jalopy -->
<property key="checkstyle.maxlinelen" value="100"/>
<property key="checkstyle.allow.protected" value="true" />
<property key="checkstyle.maxmethodlen" value="500" />
<property key="checkstyle.maxconstructorlen" value="500" />
</checkstyle>
</target>
<!-- ================================================================= -->
<!-- Runs Chainsaw -->
<!-- ================================================================= -->
<target name="oroCheck" >
<condition property="chainsaw-libraries-present">
<and>
<isset property="regexp.oro.jar" />
<available file="${regexp.oro.jar}"/>
</and>
</condition>
</target>
<target name="chainsawCheck" depends="oroCheck" if="chainsaw-libraries-present">
<echo message="Chainsaw dependant libraries present."/>
</target>
<target name="chainsawRunCheck" depends="chainsawCheck">
<fail unless="chainsaw-libraries-present" message="Chainsaw v2 needs Jakarta ORO, and it appears your are missing the Jakarta ORO package. Please check the build.properties file."/>
</target>
<target name="chainsaw" depends="chainsawRunCheck, build.chainsaw, log4j.jar, log4j-chainsaw.jar" description="Builds and runs Chainsaw v2" >
<!-- Need to fork to avoid problems -->
<java classname="org.apache.log4j.chainsaw.LogUI" fork="yes"
classpath="${jar.dest}/${log4j.jar};${jar.dest}/${log4j-chainsaw.jar};${ant.home}/lib/crimson.jar;${regexp.oro.jar}">
</java>
</target>
<!-- ================================================================= -->
<!-- Aactual work is done in the dependencies. -->
<!-- ================================================================= -->
<target name="jar" depends="log4j.jar, log4j-chainsaw.jar, log4j-lf5.jar">
</target>
<!-- ================================================================= -->
<!-- Create log4j.jar, excluding tests and other odds and ends. -->
<!-- ================================================================= -->
<target name="log4j.jar" depends="build">
<delete>
<fileset dir="${jar.dest}">
<include name="${log4j.jar}"/>
</fileset>
</delete>
<jar jarfile="${jar.dest}/${log4j.jar}" basedir="${javac.dest}"
includes="${stem}/*.class, ${stem}/xml/log4j.dtd,
${stem}/config/*.class,
${stem}/helpers/*.class,
${stem}/spi/*.class,
${stem}/net/*.class,
${stem}/jdbc/*.class,
${stem}/varia/*.class,
${stem}/nt/*.class,
${stem}/rolling/*.class,
${stem}/xml/*.class,
${stem}/jmx/*.class,
${stem}/pattern/*.class,
${stem}/or/*.class,
${stem}/or/sax/*.class,
${stem}/or/jms/*.class,
${stem}/plugins/*.class,
${stem}/config/*.class"
excludes="**/UnitTest**">
<manifest>
<attribute name="Manifest-version" value="1.0"/>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Implementation-Vendor" value="APache Software Foundation"/>
</section>
</manifest>
</jar>
</target>
<!-- ================================================================= -->
<!-- Create log4j-chainsaw.jar, excluding everything else -->
<!-- ================================================================= -->
<target name="log4j-chainsaw.jar" depends="build">
<delete>
<fileset dir="${jar.dest}">
<include name="${log4j-chainsaw.jar}"/>
</fileset>
</delete>
<copy todir="${javac.dest}">
<fileset dir="src/java" includes="**/chainsaw/**/*.properties"/>
<fileset dir="src/java" includes="**/chainsaw/*.properties"/>
<fileset dir="src/java" includes="**/chainsaw/**/*.xml"/>
<fileset dir="src/java" includes="**/chainsaw/**/*.gif"/>
<fileset dir="src/java" includes="**/chainsaw/**/*.html"/>
<fileset dir="src/java" includes="**/chainsaw/*.jpg"/>
<fileset dir="src/java" includes="**/chainsaw/**/*.jpg"/>
<fileset dir="src/java" includes="**/chainsaw/**/LICENCE"/>
</copy>
<jar jarfile="${jar.dest}/${log4j-chainsaw.jar}" basedir="${javac.dest}"
includes="${stem}/chainsaw/*.class,
${stem}/chainsaw/prefs/*.class,
${stem}/chainsaw/icons/*.class,
${stem}/chainsaw/icons/*.gif,
${stem}/chainsaw/*.jpg,
${stem}/chainsaw/**/*.xml,
${stem}/chainsaw/**/*.html,
${stem}/chainsaw/**/*.properties,
${stem}/chainsaw/icons/*.jpg,
${stem}/chainsaw/icons/LICENCE"
excludes="**/UnitTest**">
<manifest>
<attribute name="Manifest-version" value="1.0"/>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
<attribute name="Main-Class" value="org.apache.log4j.chainsaw.LogUI"/>
<attribute name="Class-Path" value="${log4j.jar}"/>
</manifest>
</jar>
</target>
<!-- ================================================================= -->
<!-- Create log4j-lf5.jar, excluding everything else -->
<!-- ================================================================= -->
<target name="log4j-lf5.jar" depends="build">
<delete>
<fileset dir="${jar.dest}">
<include name="${log4j-lf5.jar}"/>
</fileset>
</delete>
<jar jarfile="${jar.dest}/${log4j-lf5.jar}" basedir="${javac.dest}"
includes="${stem}/lf5/**/*.class,
${stem}/lf5/**/*.properties,
${stem}/lf5/**/*.gif"
excludes="**/UnitTest**">
<manifest>
<attribute name="Manifest-version" value="1.0"/>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Implementation-Vendor" value="APache Software Foundation"/>
</section>
<attribute name="Main-Class" value="org.apache.log4j.lf5.StartLogFactor5"/>
<attribute name="Class-Path" value="${log4j.jar}"/>
</manifest>
</jar>
</target>
<!-- ================================================================= -->
<!-- This target builds the javadoc files. -->
<!-- ================================================================= -->
<target name="javadoc" depends="init">
<mkdir dir="${javadoc.dest}" />
<javadoc sourcepath="${java.source.dir}"
destdir="${javadoc.dest}"
packagenames="org.apache.log4j,
org.apache.log4j.plugins,
org.apache.log4j.config,
org.apache.log4j.helpers,
org.apache.log4j.jmx,
org.apache.log4j.lf5,
org.apache.log4j.net,
org.apache.log4j.nt,
org.apache.log4j.or,
org.apache.log4j.jdbc,
org.apache.log4j.or.sax,
org.apache.log4j.or.jms,
org.apache.log4j.performance,
org.apache.log4j.rolling,
org.apache.log4j.spi,
org.apache.log4j.varia,
org.apache.log4j.chainsaw,
org.apache.log4j.xml,
org.apache.log4j.xml.examples"
additionalparam="-breakiterator"
version="true"
protected="true"
author="true"
use="true"
overview="${docs.dest}/overview.html"
doctitle="log4j version ${version}&lt;br&gt;API Specification"
windowtitle="Log4j Version ${version}"
header="&lt;b&gt;Log4j ${version}&lt;/b&gt;"
bottom="Copyright 2000-2003 Apache Software Foundation.">
<link href="http://java.sun.com/products/jdk/1.3/docs/api"/>
<link href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
<classpath refid="compile.classpath"/>
<classpath path="${regexp.oro.jar}"/>
<classpath path="${avalon-framework.jar}"/>
</javadoc>
</target>
<!-- ============================================== -->
<!-- Build the site files using Anakia -->
<!-- ============================================== -->
<target name="prepareSite2">
<available classname="org.apache.velocity.anakia.AnakiaTask"
property="AnakiaTask.present">
<classpath refid="site2.classpath"/>
</available>
</target>
<target name="checkSite2" depends="prepareSite2" unless="AnakiaTask.present">
<echo>
AnakiaTask is not present! Please check to make sure that
velocity.jar is in your classpath.
</echo>
</target>
<target name="site2" depends="checkSite2" if="AnakiaTask.present">
<taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask">
<classpath refid="site2.classpath"/>
</taskdef>
<anakia basedir="${xdocs.src}" destdir="${docs.dest}/"
extension=".html"
style="site.vsl"
projectFile="stylesheets/project.xml"
excludes="**/stylesheets/**, empty.xml, lf5/**"
includes="**/*.xml"
lastModifiedCheck="true"
templatePath="${jakarta-site2}/xdocs/stylesheets">
</anakia>
<anakia basedir="${xdocs.src}" destdir="${docs.dest}/"
extension=".html"
style="site.vsl"
projectFile="stylesheets/lf5.xml"
excludes="**/stylesheets/**, empty.xml"
includes="lf5/*.xml"
lastModifiedCheck="true"
templatePath="${jakarta-site2}/xdocs/stylesheets">
</anakia>
</target>
<!-- ================================================================= -->
<!-- Build a complete distribution. Results go to ${dist.images} -->
<!-- ================================================================= -->
<target name="dist" depends="init, clean, javadoc, jar, site2">
<delete verbose="true">
<fileset dir=".">
<patternset>
<include name="**/*.bak"/>
<include name="dist/velocity.log"/>
<include name="${BSTEM}/**/temp*"/>
<include name="${BSTEM}/performance/test"/>
<include name="${BSTEM}/test/current.*"/>
<include name="${BSTEM}/test/current.*"/>
<include name="${BSTEM}/examples/test"/>
<include name="${BSTEM}/test/logging.*"/>
<include name="${BSTEM}/test/log4j.properties"/>
<include name="{$BSTEM}/test/socket.lcf"/>
<include name="${BSTEM}/test/file"/>
<include name="${BSTEM}/test/output.*"/>
<include name="${BSTEM}/nt/EventLogCategories.dbg"/>
<include name="${BSTEM}/nt/*.h"/>
<include name="${BSTEM}/nt/*.obj"/>
<include name="${BSTEM}/nt/*.idb"/>
<include name="${BSTEM}/nt/EventLogCategories.rc"/>
<include name="${BSTEM}/nt/EventLogCategories.RES"/>
<include name="${BSTEM}/nt/EventLogCategories.res"/>
<include name="${BSTEM}/nt/MSG00001.bin"/>
<include name="${BSTEM}/nt/NTEventLogAppender.lib"/>
<include name="${BSTEM}/nt/NTEventLogAppender.exp"/>
<include name="${BSTEM}/nt/vc50.idb"/>
<include name="${BSTEM}/net/test/loop.log"/>
<include name="${BSTEM}/net/test/loop.log.1"/>
<include name="${jar.dest}/manifest.mf"/>
<include name="${javac.dest}/*.class"/>
</patternset>
</fileset>
</delete>
<mkdir dir="${dist.images}" />
<mkdir dir="${dist.tmp}/jakarta-log4j-${version}" />
<copy todir="${dist.tmp}/jakarta-log4j-${version}">
<fileset dir="${base}"
includes="src/java/**,
docs/**,
examples/**,
build/*,
build.xml,
build.properties.sample,
manifest.mf,
INSTALL,
LICENSE.txt,
${log4j.jar},
dist/classes/**,
contribs/**"
excludes="make/make.loc,
**/*.bak, **/goEnv.bat,
**/Makefile, **/goEnv.bat,
docs/pub-support/*,
dist/classes/org/**,
src/java/org/apache/log4j/test/**/*,
**/.#*"/>
</copy>
<fixcrlf srcdir="${dist.tmp}/jakarta-log4j-${version}"
includes="build.sh" cr="remove"/>
<fixcrlf srcdir="${dist.tmp}/jakarta-log4j-${version}"
includes="build.bat" cr="add"/>
<chmod dir="${dist.tmp}/jakarta-log4j-${version}"
includes="build.sh" perm="+x"/>
<tar tarfile="${dist.images}/jakarta-log4j-${version}.tar"
basedir="${dist.tmp}"
includes="jakarta-log4j-${version}/**" />
<gzip src="${dist.images}/jakarta-log4j-${version}.tar"
zipfile="${dist.images}/jakarta-log4j-${version}.tar.gz" />
<zip zipfile="${dist.images}/jakarta-log4j-${version}.zip"
basedir="${dist.tmp}"
includes="jakarta-log4j-${version}/**" />
<delete dir="${dist.tmp}" />
</target>
</project>