blob: 34600710693ffdbabb1cb0120d9597b195536328 [file] [log] [blame]
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
-->
<project name="chainsaw" default="chainsaw.jar" basedir="." >
<!-- Deprecation warning? -->
<property name="deprecation" value="on"/>
<!-- Javac with debug on/off. Log4j without debug on is hard to debug, so leave this setting on. -->
<property name="debug" value="on"/>
<property name="version" value="2.10"/>
<!-- The directory where source files are stored. -->
<property name="java.source.dir" value="src/main/java/"/>
<!-- The stem where most log4j source code is located. -->
<property name="stem" value="org/apache/log4j"/>
<!-- The build.properties file defines the parth to local jar files -->
<property file="build.properties"/>
<!-- Destination for generated jar files -->
<property name="javac.dest" value="${basedir}/build"/>
<!-- the jar file for Chainsaw that will be generated -->
<property name="log4j-chainsaw.jar" value="log4j-chainsaw-${version}.jar"/>
<!-- Destination for generated jar files -->
<property name="jar.dest" value="${basedir}"/>
<!-- When building a Java Web Start distribution of Chainsaw, some Receivers with external dependencies need to be packaged into a seperate Jar -->
<property name="webstart-dependant-receivers.jar" value="webstart-dependant-receivers.jar-${version}.jar"/>
<property name="svnrepo.url" value="https://svn.apache.org/repos/asf"/>
<property name="svnsite.url" value="${svnrepo.url}/logging/site/trunk/docs/chainsaw"/>
<available property="svn-available" file="target/site-deploy/.svn"/>
<!-- Construct compile classpath -->
<path id="compile.classpath">
<pathelement location="${javac.dest}"/>
<fileset dir="${deps.dir}">
<include name="*.jar"/>
</fileset>
<pathelement location="${jms.jar}"/>
</path>
<path id="runtime.classpath">
<fileset dir="${deps.dir}">
<include name="*.jar"/>
</fileset>
<pathelement location="${log4j-chainsaw.jar}"/>
</path>
<!-- This target is invoked through the build.chainsaw target in the parent build file
which depends on build.core ensuring that log4j core gets built before. -->
<target name="build.chainsaw" depends="vfs">
<mkdir dir="${javac.dest}" />
<javac deprecation="${deprecation}"
srcdir="${java.source.dir}"
debug="${debug}"
destdir="${javac.dest}">
<patternset>
<include name="**/*.java"/>
<exclude name="org/apache/log4j/chainsaw/vfs/**/*.java" unless="vfs-present"/>
</patternset>
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="log4jCheck">
<available classname="org.apache.log4j.Logger" property="log4jJarsPresent">
<classpath refid="compile.classpath"/>
</available>
<fail unless="log4jJarsPresent">
One or more of the following files are missing:
${log4j.jar}, log4j-xml.jar log4j-optional.jar
</fail>
</target>
<target name="vfsCheck">
<available classname="org.apache.commons.vfs.FileObject" property="vfs-present">
<classpath refid="compile.classpath"/>
</available>
<echo>VFS Present: ${vfs-present}</echo>
</target>
<target name="vfs" depends="vfsCheck" unless="vfs-present">
<echo>
Could not find vfs classes (http://jakarta.apache.org/commons/sandbox/vfs/).
Did you forget to add the commons-vfs jar to the directory specified by deps.dir
in build.properties?
Chainsaw will be built but will not include support
for VFSLogFilePatternReceiver
</echo>
</target>
<target name="JmDNSCheck">
<available classname="javax.jmdns.JmDNS" property="jmdns-present">
<classpath refid="compile.classpath"/>
</available>
<echo>JmDNS Present: ${jmdns-present}</echo>
</target>
<target name="BuildZeroConfJar" depends="JmDNSCheck, build.chainsaw" if="jmdns-present">
<javac deprecation="${deprecation}"
srcdir="${java.source.dir}"
debug="${debug}"
destdir="${javac.dest}">
<patternset>
<include name="**/zeroconf/*.java"/>
</patternset>
<classpath refid="compile.classpath"/>
</javac>
<jar jarfile="${jar.dest}/log4j-chainsaw-zeroconf.jar" basedir="${javac.dest}"
includes="${stem}/**/zeroconf/*.class" excludes="**/*Test*.class">
<manifest>
<attribute name="Manifest-version" value="1.0"/>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j ZeroConf optional extras"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
</jar>
</target>
<target name="getdeps">
<mkdir dir="deps-dl"/>
<get src="http://www.apache.org/dist/jakarta/commons/logging/binaries/commons-logging-1.0.4.zip" dest="deps-dl/commons-logging-1.0.4.zip" verbose="true" usetimestamp="true"/>
<unzip src="deps-dl/commons-logging-1.0.4.zip" dest="deps-dl/unpack">
<patternset>
<include name="commons-logging-1.0.4/commons-logging*.jar"/>
</patternset>
</unzip>
<move todir="${deps.dir}" >
<fileset dir="deps-dl">
<include name="**/*.jar"/>
</fileset>
<mapper type="flatten"/>
</move>
</target>
<!-- ================================================================= -->
<!-- Runs Chainsaw -->
<!-- ================================================================= -->
<target name="chainsaw" depends="chainsaw.jar, log4jCheck"
description="Build and run Chainsaw v2 from jar file (generates Chainsaw jar if necessary)" >
<!-- Need to fork to avoid problems -->
<java classname="org.apache.log4j.chainsaw.LogUI" fork="yes">
<sysproperty key="log4j.debug" value="${log4j.debug}"/>
<classpath refid="runtime.classpath"/>
</java>
</target>
<!-- this target can't be run in Gump mode, because the external project won't be available -->
<target name="javaDocLog4jReceivers" unless="gump">
<!-- JavaDoc up some Receiver and other stuff we want to be able to ship with Chainsaw-->
<javadoc sourcepath="${java.source.dir}"
destdir="${javac.dest}"
version="true"
author="true"
use="true"
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."
>
<fileset dir="src/" defaultexcludes="yes">
<include name="**/*Receiver.java" />
</fileset>
<fileset dir="${log4j.src}/src/" defaultexcludes="yes">
<include name="**/*Receiver.java" />
</fileset>
<classpath refid="compile.classpath"/>
</javadoc>
</target>
<!-- ================================================================= -->
<!-- Create log4j-chainsaw.jar, excluding everything else -->
<!-- ================================================================= -->
<target name="chainsaw.jar" depends="build.chainsaw, BuildZeroConfJar, javaDocLog4jReceivers">
<delete>
<fileset dir="${jar.dest}">
<include name="${log4j-chainsaw.jar}"/>
</fileset>
</delete>
<copy todir="${javac.dest}">
<fileset dir="src/main/java" includes="**/chainsaw/**/*"/>
</copy>
<jar jarfile="${jar.dest}/${log4j-chainsaw.jar}" basedir="${javac.dest}"
includes="${stem}/chainsaw/*.class,
${stem}/**/*.html,
**/*.css,
**/resources/*,
${stem}/**/*BeanInfo.class,
${stem}/chainsaw/**/*.class,
${stem}/chainsaw/layout/*,
${stem}/chainsaw/icons/*.gif,
${stem}/chainsaw/*.jpg,
${stem}/chainsaw/**/*.xml,
${stem}/chainsaw/**/*.html,
${stem}/chainsaw/**/*.properties,
${stem}/chainsaw/receivers/known.receivers,
${stem}/chainsaw/icons/*.jpg,
${stem}/chainsaw/icons/LICENCE"
excludes="**/UnitTest**">
<!-- ZeroConf stuff goes in it's own Jar -->
<exclude name="**/zeroconf/**/*" />
<!-- VFS stuff goes in it's own Jar -->
<exclude name="**/vfs/**/*" />
<!-- we need to exclude the JMS + DB Receiver BeanInfo for webstart purposes -->
<exclude name="**/JMS*BeanInfo.class" if="webstart" />
<exclude name="**/DB*BeanInfo.class" if="webstart" />
<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>
<jar jarfile="${jar.dest}/log4j-chainsaw-vfs.jar" basedir="${javac.dest}"
includes="${stem}/chainsaw/vfs/*.class" >
<manifest>
<attribute name="Manifest-version" value="1.0"/>
<section name="org/apache/log4j/">
<attribute name="Implementation-Title" value="log4j VFS"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
</section>
</manifest>
</jar>
</target>
<!-- ================================================================= -->
<!-- These targets are for when we need to create a Java Web start -->
<!-- distribution of Chainsaw -->
<!-- ================================================================= -->
<target name="webstart-dependant-receivers.jar" depends="build.chainsaw">
<delete>
<fileset dir="${jar.dest}">
<include name="${webstart-dependant-receivers.jar}"/>
</fileset>
</delete>
<jar jarfile="${jar.dest}/${webstart-dependant-receivers.jar}" basedir="${javac.dest}"
includes="${stem}/**/JMSReceiver*.class, ${stem}/**/DBReceiver*.class">
<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>
<target name="shellscript-taskdef">
<javac deprecation="${deprecation}"
srcdir="anttasks-src"
debug="${debug}"
destdir="${javac.dest}">
<patternset>
<include name="**/*.java"/>
</patternset>
<classpath refid="compile.classpath"/>
</javac>
<copy todir="${javac.dest}">
<fileset dir="anttasks-src">
<include name="*.jnlp"/>
</fileset>
</copy>
<taskdef name="createshellscripts" classpathref="compile.classpath" classname="org.apache.chainsaw.ant.CreateShellScripts" />
</target>
<target name="webstart" depends="shellscript-taskdef">
<tstamp />
<property name="chainsaw-bundle.zip" value="chainsaw-bundle-${DSTAMP}.zip" />
<property name="chainsaw.dmg" value="chainsaw-${DSTAMP}.dmg" />
<property name="webstart-bundle.zip" value="webstart-bundle-${DSTAMP}.zip" />
<property name="webstart" value="true"/>
<antcall target="chainsaw.jar"/>
<antcall target="webstart-dependant-receivers.jar"/>
<delete dir="webstart-dist"></delete>
<!-- TODO Now copy all the jars into a new webstart-dist directory -->
<copy todir="webstart-dist">
<fileset file="packaging/chainsaw.*"/>
<fileset dir="lib" />
<fileset dir=".">
<include name="log4j-chain*.jar"/>
<include name="log4j-zeroconf*.jar"/>
<!--<include name="webstart*.jar"/> -->
</fileset>
</copy>
<createshellscripts outputLocation="webstart-dist" scriptType="shell">
<fileset dir="webstart-dist" includes="*.jar">
<exclude name="commons*.jar"/>
<exclude name="*vfs*.jar"/>
<exclude name="*-jms-*.jar"/>
<exclude name="*-db-*.jar"/>
</fileset>
</createshellscripts>
<!-- Webstart distribution can't have VFS because of stupid classloading rules, so we exclude it-->
<createshellscripts outputLocation="webstart-dist" scriptType="webstart">
<fileset dir="webstart-dist" includes="*.jar">
<exclude name="commons*.jar"/>
<exclude name="*vfs*.jar"/>
<exclude name="*-jms-*.jar"/>
<exclude name="*-db-*.jar"/>
</fileset>
</createshellscripts>
<input
message="Please enter key password:"
addproperty="keypass"
/>
<signjar verbose="false" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" >
<fileset dir="webstart-dist">
<include name="*.jar"/>
</fileset>
</signjar>
<zip destfile="${chainsaw-bundle.zip}" >
<zipfileset dir="webstart-dist">
<include name="*.jar"/>
<include name="*.bat"/>
<include name="*.sh"/>
<exclude name="commons*.jar"/>
<exclude name="*vfs*.jar"/>
<exclude name="*-jms-*.jar"/>
<exclude name="*-db-*.jar"/>
</zipfileset>
</zip>
</target>
<!-- This target can only be run on an OS X computer and requires
see http://www.loomcom.com/jarbundler/
-->
<target name="iSaw" depends="webstart">
<delete dir="iSaw-Dist" failonerror="false"/>
<delete dir="Chainsaw.app" failonerror="false"/>
<delete dir="Chainsaw-app" failonerror="false"/>
<mkdir dir="iSaw-dist" />
<mkdir dir="Chainsaw-app" />
<copy file="${webstart-dependant-receivers.jar}" todir="iSaw-dist"/>
<copy file="${log4j-chainsaw.jar}" todir="iSaw-dist"/>
<copy todir="iSaw-dist">
<fileset dir="webstart-dist">
<include name="*.jar" />
<exclude name="commons*.jar"/>
<exclude name="*vfs*.jar"/>
</fileset>
</copy>
<taskdef name="jarbundler"
classpath="antlibs/jarbundler-1.4.jar"
classname="com.loomcom.ant.tasks.jarbundler.JarBundler" />
<jarbundler dir="."
name="Chainsaw"
mainclass="org.apache.log4j.chainsaw.LogUI"
icon="packaging/logo.icns"
version="2.1.0"
infostring="Chainsaw"
aboutmenuname="Chainsaw"
bundleid="org.apache.log4j.chainsaw.ChainsawBundle"
developmentregion="English"
signature="chainsaw"
jvmversion="1.4+"
vmoptions="-Xms32m -Xmx256m"
smalltabs="true"
antialiasedgraphics="true"
antialiasedtext="true"
liveresize="true"
growboxintrudes="false"
screenmenu="true" >
<jarfileset dir="iSaw-dist">
<include name="**/*.jar" />
</jarfileset>
</jarbundler>
<move file="Chainsaw.app" todir="Chainsaw-app" />
<echo message="Creating DMG image"/>
<exec executable="hdiutil">
<arg line="create -srcfolder Chainsaw-app ${chainsaw.dmg}"/>
</exec>
</target>
<!-- NOTE: you'll need JSch in your Ant ext libs area for this to work -->
<target name="distribution" depends="webstart, iSaw" description="Builds the complete distribution (Webstart, zip + OSX)">
<delete dir="distribution" failonerror="false"/>
<mkdir dir="distribution"/>
<copy todir="distribution">
<fileset dir=".">
<include name="**/${chainsaw-bundle.zip}"/>
<include name="${chainsaw.dmg}" />
</fileset>
</copy>
<zip destfile="distribution/${webstart-bundle.zip}" >
<zipfileset dir="webstart-dist" includes="*.jnlp"/>
<zipfileset dir="webstart-dist" prefix="lib" includes="*.jar"/>
</zip>
<!-- TODO copy, unpack the os X image template, update the files, close the image, move into distribution directory -->
<input addproperty="dist.password" message="Please type in your remote password: (Warning:What you type will appear in plain text on console.)"></input>
<echo message="${dist.user}, ${dist.password}, ${dist.dest}, ${dist.keyfile}" />
<!-- NOTE: you HAVE to use key based authentication, otherwise it just won't work -->
<scp todir="${dist.user}@people.apache.org:${dist.dest}" passphrase="${dist.password}" keyfile="${dist.keyfile}" verbose="true">
<fileset dir="distribution">
<include name="**/*.*"/>
</fileset>
</scp>
</target>
<!-- ================================================================= -->
<!-- Remove all generated (compiled) class files. -->
<!-- ================================================================= -->
<target name="clean" description="Delete all compiled files.">
<mkdir dir="${javac.dest}" />
<delete dir="${javac.dest}"/>
<delete>
<fileset dir="${jar.dest}" includes="log4j-chainsaw*.jar"/>
</delete>
</target>
<target name="checkout-site" unless="svn-available">
<exec executable="svn">
<arg value="co"/>
<arg value="${svnsite.url}"/>
<arg value="target/site-deploy"/>
</exec>
</target>
<target name="update-site" if="svn-available">
<exec executable="svn" dir="target/site-deploy" failonerror="true">
<arg value="update"/>
</exec>
</target>
<target name="post-site" depends="checkout-site, update-site"/>
<target name="mime=html">
<exec executable="svn">
<arg value="propset"/>
<arg value="svn:mime-type"/>
<arg value="text/html"/>
<arg value="${src.html}"/>
</exec>
</target>
<target name="mime=css">
<exec executable="svn">
<arg value="propset"/>
<arg value="svn:mime-type"/>
<arg value="text/css"/>
<arg value="${src.css}"/>
</exec>
</target>
<target name="site-deploy">
<!-- Add any new files (and generate innocuous warnings for the existing content) -->
<delete file="target/site-deploy/svn-commit.tmp~"/>
<exec executable="bash" dir="target/site-deploy" failonerror="true">
<arg line='-c "svn add --force *"'/>
</exec>
<taskdef name="foreach" classname="net.sf.antcontrib.logic.ForEach" />
<foreach target="mime=html" param="src.html">
<path>
<fileset dir="target/site-deploy" includes="**/*.html"/>
</path>
</foreach>
<foreach target="mime=css" param="src.css">
<path>
<fileset dir="target/site-deploy" includes="**/*.css"/>
</path>
</foreach>
<!-- requires that SVN_EDITOR, VISUAL or EDITOR being set to edit commit description -->
<exec executable="svn" dir="target/site-deploy" failonerror="true">
<arg value="commit"/>
</exec>
</target>
</project>