ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "North Alex" <Alex.No...@tapiola.fi>
Subject RE: ANT Inside IBM WebSphere Application Developer
Date Thu, 10 Apr 2003 05:56:21 GMT
Hi

Sorry it took so long to respond ... I had a typical Monday ... only it
got extended :P

Anyway, here is a description of how we use ANT from within WSAD.  The
main reason we started to do this was to avoid the initial
installation/configuration on each workstation and also the upgrade
problems when we want to take a new version of a 3rd party library or,
as has happened, an upgrade of the IDE itself.  The only thing that has
to be done to each workstation is to make sure that 'java' and 'javadoc'
are in the path.

There are 3 "layers" to the scripts.  

1. build.xml
The script in the WSAD project.  

2. common-build.xml
Then we have a common build script that contains useful tasks for any
project, such as building JavaDocs plus it contains the calls for
executing targets in an external version of ANT.
This script exists in one place (under source control for us) and is
used by many projects.

3. common-external-build.xml
Finally we have the script that does the actual work in the ANT version
we want.


1. build.xml:
------------
<?xml version="1.0" encoding="UTF-8"?>
<project name="CommonDAO" default="Compile">

	<!-- basic component info -->
	<property name = "component.name" 	 	value =
"commonDAO"/>
	<property name = "component.version" 	value =
"KAY_R_COMMON_DAO_3.1.1"/>
	<property name = "root.dir" 		 	value =
"C:\Z\vob_common\src\Java_sources\${component.name}"/>
	<property name = "html.title"		 	value = "Common
DAO ${component.version}"/>

	<!-- physical locations -->
	<property name = "classes.dir" 	 	value =
"${root.dir}\bin"/>
	<property name = "source.dir" 	 	value =
"${root.dir}\src"/>
	<property name = "test.source.dir" 	 	value =
"${root.dir}\test"/>
	<property name = "javadoc.dir" 		value =
"${root.dir}\${component.version}-api"/>

	<!-- ant related -->
	<property name = "script.root.dir"	 	value =
"C:\Z\vob_devtools\ant\scripts"/>
	<property name = "common.build"	 	value =
"${script.root.dir}\common-build.xml"/>

	<!-- compile all source for this project -->
	<target name="Compile" depends="clean">
		<projectBuild ProjectName="${component.name}"
failonerror="true"
			DebugCompilation="true" BuildType="full"/>
	</target>	

	<!-- Build the JavaDoc API docs -->
	<target name="JavaDoc">
		<ant antfile="${common.build}" target="javadoc"/>
	</target>

</project>


2. common-build.xml:
-------------------
<?xml version="1.0"?>
<project name="Common ANT Script" default="javadoc">
	<!-- ant related -->
	<property name = "ext.ant.home" 	value =
"C:\Z\vob_devtools\ant\jakarta-ant"/>
	<property name = "ext.ant"	    	value =
"${ext.ant.home}\bin\ant.bat"/>
	<property name = "script.root.dir"	value =
"C:\Z\vob_devtools\ant\scripts"/>
	<property name = "ext.ant.params" 	value = "-buildfile
'${script.root.dir}\common-external-build.xml'
-Dext.ant.home='${ext.ant.home}'"/>

	<!-- Build the JavaDocs -->
	<target name="javadoc">
		<mkdir dir="${javadoc.dir}"/>
		<javadoc destdir="${javadoc.dir}" public="true"
use="true"
			notree="false" nonavbar="false" noindex="false"
			splitindex="true" author="true" version="true"
			nodeprecatedlist="false" nodeprecated="false"
			sourcepath="${source.dir}"
			packagenames="fi.tapiola.*"
			classpath="${classes.dir}" 
			doctitle="${html.title}"/>
	</target>

	<target name="checkstyle">
		<exec executable="${ext.ant}" failonerror="true">
			<arg line="${ext.ant.params}"/>
			<arg line="checkstyle"/>
			<arg line='-Dsource.dir="${source.dir}"'/>
			<arg line='-Dreport.dir="${report.dir}"'/>
		</exec>
	</target>

</project>


3. common-external-build.xml

<?xml version="1.0"?>
<project name="Common External ANT Script" default="depend">

	<!-- 3rd party lib location -->
	<property name = "3rdparty.dir"	value =
"C:\Z\vob_devtools\ant\3rd-party"/>

	<!-- task(s) related -->
    <!-- CheckStyle -->
	<property name = "checkstyle.report.dir" value =
"${report.dir}\checkstyle"/>
	<property name = "checkstyle.report"     value =
"checkstyle-report"/>
	<property name = "checkstyle.xsl"        value =
"${3rdparty.dir}\checkstyle-3.0\contrib\checkstyle-noframes.xsl"/>
      <property name = "checkstyle.config"     value =
"${3rdparty.dir}\checkstyle-3.0\docs\checkstyle_checks.xml"/>

	<target name="init">
		<mkdir dir="${report.dir}"/>
	</target>

	<!-- Checkstyle -->
	<target name="checkstyle" depends="init">
		<mkdir dir="${checkstyle.report.dir}"/>
		<taskdef name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"
	
classpath="${3rdparty.dir}\checkstyle-3.0\checkstyle-all-3.0.jar"/>
		
		<checkstyle config="${checkstyle.config}"
failOnViolation="false">
			<fileset dir="${source.dir}"
includes="**/*.java"/>
			<formatter type="xml"
toFile="${checkstyle.report.dir}\${checkstyle.report}.xml"/>
		</checkstyle>
		<style basedir="${checkstyle.report.dir}"
in="${checkstyle.report.dir}\${checkstyle.report}.xml"
out="${checkstyle.report.dir}\${checkstyle.report}.html"
			style="${checkstyle.xsl}"/>
	</target>
</project>


... and that should be it.  A very flexible system that allows us to
provide common tasks for use, update tasks, ANT version, and even use
different ANT versions for different tasks if needed.

Feel free to bug me if anything is not clear.

<= Alex =>

Mime
View raw message