alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (build.xml)

This example Java source code file (build.xml) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

ant, default, run, these

The build.xml Java example source code

<project name="testing-log4j-bridge" default="usage" basedir=".">

	<property name="lbversion" value="0.9.8-SNAPSHOT" />
    <property name="slf4jversion" value="1.4.2" />
	<property name="source.home" value="./src/main/java/" />
	<property name="javac.dest.12" value="./target/classes12/" />
	<property name="javac.dest.13" value="./target/classes13/" />
	<property name="lib" value="./lib" />

	<property name="deprecation" value="on" />

	<path id="basic.classpath">
		<pathelement location="${source.home}" />
		<pathelement location="${lib}/junit-3.8.1.jar" />
	</path>

	<path id="log4j12.classpath">
		<path refid="basic.classpath" />
		<pathelement location="${javac.dest.12}" />
		<pathelement location="${lib}/log4j-1.2.14.jar" />
	</path>

	<path id="log4j13.classpath">
		<path refid="basic.classpath" />
		<pathelement location="${javac.dest.13}" />
		<pathelement location="${lib}/log4j-1.3alpha-8.jar" />
	</path>

	<path id="los.classpath">
		<path refid="basic.classpath" />
		<pathelement location="${lib}/log4j-over-slf4j-${slf4jversion}.jar" />
		<pathelement location="${lib}/logback-classic-${lbversion}.jar" />
		<pathelement location="${lib}/logback-core-${lbversion}.jar" />
		<pathelement location="${lib}/slf4j-api-${slf4jversion}.jar" />
	</path>

	<!-- ================================================================= -->
	<!-- Default target                                                    -->
	<!-- ================================================================= -->
	<target name="usage">
		<echo>      
      These are some of the targets supported by this ANT build scpript:

      all - run all available tests
      refresh - copy required jar files to the lib directory
    </echo>
	</target>

  <delete>
    <fileset dir="." includes="**/*.bak"/>
  </delete>

  <target name="refresh">
    <delete>
      <fileset dir="lib">
        <include name="logback-*.jar"/>
        <include name="log4j-bridge-*.jar"/>
      </fileset>
    </delete>
    <copy file="../../slf4j-api/target/slf4j-api-${slf4jversion}.jar" todir="lib/"/>
    <copy file="../target/log4j-over-slf4j-${slf4jversion}.jar" todir="lib/"/>

  </target>


	<target name="init">
		<mkdir dir="${javac.dest.12}" />
		<mkdir dir="${javac.dest.13}" />
	</target>

	<target name="clean">
		<delete>
			<fileset dir="${javac.dest.12}" includes="**" />
			<fileset dir="${javac.dest.13}" includes="**" />
		</delete>
	</target>

	<target name="build_log4j12" depends="init">
		<javac srcdir="${source.home}" 
			     destdir="${javac.dest.12}" 
			     includes="**/Log4j12Calls.java" 
			     deprecation="${deprecation}" debug="on">
			<classpath refid="log4j12.classpath" />
		</javac>
	</target>

	<target name="build_log4j13" depends="init">
		<javac srcdir="${source.home}" 
			     destdir="${javac.dest.13}" 
			     includes="**/Log4j13Calls.java" deprecation="${deprecation}" debug="on">
			<classpath refid="log4j13.classpath" />
		</javac>
	</target>
	
	<target name="build_loggerTest" depends="init">
		<javac srcdir="${source.home}" 
			     destdir="${javac.dest.12}" 
			     includes="**/LoggerTest.java" 
			     deprecation="${deprecation}" debug="on">
			<classpath refid="los.classpath" />
		</javac>
	</target>

	<!-- ================================================================= -->
	<!-- Run tests                                                     -->
	<!-- ================================================================= -->
	<target name="all" depends="test12, test13, loggerTest" />


	<target name="loggerTest" depends="build_loggerTest">
		<junit printsummary="yes" fork="yes" haltonfailure="yes">
			<classpath refid="los.classpath" />
			<classpath location="${javac.dest.12}" />
			<formatter type="plain" usefile="false" />
			<test name="test.LoggerTest" />
		</junit>
	</target>
	
	<target name="test12" depends="build_log4j12">
		<junit printsummary="yes" fork="yes" haltonfailure="yes">
			<classpath refid="los.classpath" />
			<classpath location="${javac.dest.12}" />
			<formatter type="plain" usefile="false" />
			<test name="test.Log4j12Calls" />
		</junit>
	</target>

	<target name="test13" depends="build_log4j13">
		<junit printsummary="yes" fork="yes" haltonfailure="yes">
			<classpath refid="los.classpath" />
			<classpath location="${javac.dest.13}" />
			<formatter type="plain" usefile="false" />
			<test name="test.Log4j13Calls" />
		</junit>
	</target>

</project>

Other Java examples (source code examples)

Here is a short list of links related to this Java build.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.