2
This build.xml snippet contains Forrest targets for Ant 1.5+. It checks that
3
the user has set ${forrest.home}, either in one of:
8
or with the FORREST_HOME environment variable, and prints an informative error
12
1) Copy this file to somewhere in your project.
13
2) Add the following to the top of your project's Ant build.xml script
17
<!ENTITY forrest-targets SYSTEM "file:./forrest-targets.ent">
20
3) Before the closing '</project>' in your build.xml, add this:
24
This is like expanding a macro: it pulls in the contents of this file.
26
A minimal build.xml would thus be:
29
<!ENTITY forrest-targets SYSTEM "file:./forrest-targets.ent">
32
<project default="site">
37
<target name="site" depends="forrest.init" description="Generates static HTML documentation">
38
<ant antfile="${forrest.home}/forrest.antproxy.xml" target="site"/>
41
<target name="webapp" depends="forrest.init" description="Generates an unpackaged webapp of the website">
42
<ant antfile="${forrest.home}/forrest.antproxy.xml" target="webapp"/>
45
<target name="war" depends="forrest.init" description="Generates a .war file containing the website">
46
<ant antfile="${forrest.home}/forrest.antproxy.xml" target="war"/>
49
<target name="validate" depends="forrest.init" description="Validates XML documentation files">
50
<ant antfile="${forrest.home}/forrest.antproxy.xml" target="validate"/>
53
<target name="forrest.init" depends="forrest.sethome, forrest.home.defined"/>
55
<target name="forrest.sethome" depends="forrest.loadenv,
56
forrest.checkenv, forrest.checkhome, forrest.check-build.properties,
57
forrest.check-project.properties, forrest.check-ant.properties,
58
forrest.check-.ant.properties"/>
60
<target name="forrest.loadenv" unless="forrest.home.present">
61
<property environment="env"/>
62
<echo level="verbose">Forrest: Got ${env.FORREST_HOME}</echo>
65
<target name="forrest.checkenv" if="env.FORREST_HOME">
66
<echo level="verbose">Found $FORREST_HOME..</echo>
67
<property name="forrest.home" location="${env.FORREST_HOME}"/>
68
<echo level="verbose">forrest.home set to ${forrest.home}</echo>
69
<available file="${forrest.home}" type="dir" property="forrest.home.present"/>
73
<target name="forrest.checkhome">
74
<available file="${forrest.home}" type="dir" property="forrest.home.present"/>
75
<available file="build.properties" type="file" property="build.properties.present"/>
76
<available file="project.properties" type="file" property="project.properties.present"/>
77
<available file="ant.properties" type="file" property="ant.properties.present"/>
78
<available file=".ant.properties" type="file" property=".ant.properties.present"/>
81
<!-- No we can't extract the commonalities below into an antcall'ed target,
82
because it wouldn't be able to set forrest.home -->
83
<target name="forrest.check-build.properties" unless="forrest.home.present"
84
if="build.properties.present">
85
<echo level="verbose">Forrest: Checking build.properties..</echo>
86
<loadproperties srcfile="build.properties">
89
<contains value="forrest.home"/>
93
<available file="${forrest.home}" type="dir" property="forrest.home.present"/>
97
<target name="forrest.check-project.properties" unless="forrest.home.present"
98
if="project.properties.present">
99
<echo level="verbose">Forrest: Checking project.properties..</echo>
100
<loadproperties srcfile="project.properties">
103
<contains value="forrest.home"/>
107
<available file="${forrest.home}" type="dir" property="forrest.home.present"/>
110
<target name="forrest.check-ant.properties" unless="forrest.home.present"
111
if="ant.properties.present">
112
<echo level="verbose">Forrest: Checking ant.properties..</echo>
113
<loadproperties srcfile="ant.properties">
116
<contains value="forrest.home"/>
120
<available file="${forrest.home}" type="dir" property="forrest.home.present"/>
123
<target name="forrest.check-.ant.properties" unless="forrest.home.present"
124
if=".ant.properties.present">
125
<echo level="verbose">Forrest: Checking .ant.properties..</echo>
126
<loadproperties srcfile=".ant.properties">
129
<contains value="forrest.home"/>
133
<available file="${forrest.home}" type="dir" property="forrest.home.present"/>
136
<target name="forrest.home.defined" depends="forrest.sethome" unless="forrest.home.present">
137
<property name="path" value="${user.home}/xml-forrest/build/dist/shbat"/>
138
<pathconvert targetos="windows" property="winpath">
140
<pathelement location="${path}"/>
143
<pathconvert targetos="unix" property="unixpath">
151
----------------------------------------------
152
To run this target, you need Forrest installed.
153
Please do the following:
155
export CVSROOT=:pserver:anoncvs@cvs.apache.org:/home/cvspublic
156
cvs checkout xml-forrest
163
- Set FORREST_HOME as the Forrest build instructions describe
164
- Create a build.properties, with the forrest.home property pointing to
165
the forrest shbat directory, eg:
167
forrest.home=${winpath} (Windows)
168
forrest.home=${unixpath} (Unix)
170
(adjusting the path according to where your xml-forrest is)
171
----------------------------------------------
173
<fail message="Need to define $${forrest.home}"/>