Removed -target option from build. Evidentially, the -source does everything we...
[java-idp.git] / build.xml
1 <!-- Main build configutaion for Shibboleth java components - Walter Hoehn 06/04/2002 -->
2
3 <project name="Shibboleth" default="install" basedir=".">
4
5     <!-- Set global properties for this build -->
6     <property name="distname" value="shibboleth" />
7     <property name="root" value="." />
8     <property name="src" value="${root}/src/" />
9     <property name="tests" value="${root}/tests/" />
10     <property name="approot" value="${root}/webApplication/" />
11     <property name="appconfig" value="${src}/conf/" />
12     <property name="configroot" value="${root}/webAppConfig/" />
13     <property name="build" value="${approot}/WEB-INF/classes/" />
14     <property name="libdir" value="${approot}/WEB-INF/lib/" />
15     <property name="buildlibs" value="${root}/lib/" />
16     <property name="endorsed" value="${root}/endorsed/" />
17     <property name="distlibs" value="${root}/lib/" />
18     <property name="dist" value="${root}/dist/" />
19     <property name="docs" value="${root}/doc/" />
20     <property name="javadocs" value="${docs}/api/" />
21
22     <property name="year" value="2002-2005"/>
23     <property name="copyright" value="Copyright &#169; ${year} UCAID. All Rights Reserved."/>
24         
25     <!-- antcontrib tasks -->
26     <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${buildlibs}/ant-contrib.jar"/>
27         
28     <!-- Construct the CLASSPATH -->
29     <path id="build.path">
30         <pathelement path="${classpath}" />
31         <pathelement location="${build}" />
32         <fileset dir="${endorsed}">
33             <include name="**/*.jar" />
34         </fileset>
35         <fileset dir="${libdir}">
36             <include name="**/*.jar" />
37         </fileset>
38         <fileset dir="${buildlibs}">
39             <include name="**/*.jar" />
40         </fileset>
41     </path>
42
43    <path id="test.path">
44       <path refid="build.path"/>
45       <pathelement location="${tests}"/>
46     </path>
47
48
49     <!-- Prepare directory structure for project build-->
50     <target name="init">
51         <mkdir dir="${build}" />
52         <mkdir dir="${dist}" />
53         <var file="build.properties" />
54     </target>
55
56     <target name="install.init">
57         <taskdef name="xinput" classname="edu.internet2.middleware.shibboleth.utils.ant.XInput" classpath="${build}"/>
58         <typedef name="xoption" classname="edu.internet2.middleware.shibboleth.utils.ant.XInputOption" classpath="${build}"/>
59     </target>
60
61
62     <!-- This target should be run before checking code into the repository -->
63     <target name="pre-checkin" depends="compile, test-all, clean-all" />
64
65
66     <!-- Compile classes and move them to ${build} -->
67     <target name="compile" depends="init"
68         description="Compile source file, combine with schemas and conf directories">
69         <javac srcdir="${src}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
70             <classpath refid="build.path" />
71         </javac>
72         <copy todir="${build}/schemas">
73             <fileset dir="${src}/schemas"/>
74         </copy>
75         <!-- configuration is now stored outside of shibboleth.war
76         <copy todir="${build}/conf">
77             <fileset dir="${src}/conf"/>
78         </copy>
79         -->
80     </target>
81     
82     <target name="compile-tests" depends="compile">
83         <javac srcdir="${tests}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
84             <classpath refid="build.path" />
85         </javac>
86     </target>
87
88
89         <!-- Generate API docs -->
90         <target name="javadocs">
91                 <mkdir dir="${docs}" />
92                 <mkdir dir="${javadocs}" />
93                 <javadoc packagenames='edu.internet2.middleware.*'
94                         sourcepath='${src}' destdir='${javadocs}'
95                         author='true' version='true'
96                         windowtitle='Shibboleth Java API' doctitle='Shibboleth Java API'
97                         bottom='${copyright}'>
98                 <classpath refid="build.path" />
99         </javadoc>
100         </target>
101
102     <!-- Create various product distributions and move them to ${dist} -->
103
104     <target name="dist-all" depends="compile, test-all, package-all, clean-build" />
105         
106     <target name="package-all">
107         <war warfile="${dist}/${distname}.war" webxml="${configroot}/all.xml" basedir="${approot}" update="no" />
108     </target>
109
110     <target name="dist-IdP-SP" depends="compile, package-IdP-SP, clean-build" 
111         description="Build application from source, create shibboleth.war file for IdP and SP"/>
112     <target name="package-IdP-SP" depends="compile"
113         description="Create shibboleth.war file from build output and IdP-SP deployment descriptor">
114         <war warfile="${dist}/${distname}.war" webxml="${configroot}/IdP-SP.xml" basedir="${approot}" update="no" />
115     </target>
116
117     <target name="dist-wayf" depends="compile, package-wayf, clean-build" />
118     <target name="package-wayf">
119         <war warfile="${dist}/${distname}-wayf.war" webxml="${configroot}/wayf.xml" basedir="${approot}" update="no" />
120     </target>
121
122     <!-- Build utilities -->
123     <target name="build-util" depends="compile">
124         <jar jarfile="${distlibs}/shib-util.jar" basedir="${build}" />
125     </target>
126
127     
128     <!-- Cleanup after the build, test, and distribution processes -->
129     <target name="clean" depends="clean-all" />
130     <target name="clean-all" depends="clean-build, clean-dist, clean-test, clean-javadocs, clean-util" />
131     <target name="clean-build">
132         <delete dir="${build}" />
133     </target>
134     <target name="clean-test">
135         <delete>
136             <fileset dir="${root}">
137                 <include name="**/TEST*.txt" />
138             </fileset>
139         </delete>
140     </target>
141     <target name="clean-dist">
142         <delete dir="${dist}" />
143     </target>
144         <target name="clean-javadocs">
145                 <delete dir="${javadocs}" />
146         </target>
147     <target name="clean-util">
148         <delete>
149             <fileset dir="${buildlibs}">
150                 <include name="shib-util.jar" />
151             </fileset>
152         </delete>
153     </target>
154
155     <!-- Run automated tests on compiled code -->
156     <target name="test-all" depends="test-IdP, test-SP" />
157     <target name="test-IdP" depends="compile-tests">
158         <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
159                         <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
160             <classpath refid="test.path" />
161             <formatter type="plain" />
162             <test name="edu.internet2.middleware.shibboleth.aa.arp.ArpTests" />
163                         <test name="edu.internet2.middleware.shibboleth.aa.attrresolv.ResolverTests" />
164                         <test name="edu.internet2.middleware.shibboleth.common.CredentialsTests" />
165                         <test name="edu.internet2.middleware.shibboleth.common.provider.NameMapperTests" />
166                         <test name="edu.internet2.middleware.shibboleth.common.TrustTests" />
167                         <test name="edu.internet2.middleware.shibboleth.idp.provider.DNHostNameExtractionTests" />
168                         <test name="edu.internet2.middleware.shibboleth.metadata.MetadataTests" />
169         </junit>
170     </target>
171     <target name="test-SP" depends="compile-tests">
172         <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
173                         <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
174             <classpath refid="test.path" />
175             <formatter type="plain" />
176             <test name="edu.internet2.middleware.shibboleth.aap.AAPTests" />
177         </junit>
178     </target>
179     
180     <!-- Tomcat Management -->
181     <target name="setupTomcatTasks">
182         <path id="tomcat.classpath">
183                     <fileset dir="${tomcat.home}/server/lib" includes="catalina-ant.jar"/>
184             </path>
185
186         <taskdef name="tomcatStart" classname="org.apache.catalina.ant.StartTask" classpathref="tomcat.classpath"/>
187         <taskdef name="tomcatStop" classname="org.apache.catalina.ant.StopTask" classpathref="tomcat.classpath"/>
188             <taskdef name="tomcatDeploy" classname="org.apache.catalina.ant.DeployTask" classpathref="tomcat.classpath"/>
189         <taskdef name="tomcatUndeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="tomcat.classpath"/>
190         </target>
191     
192     <target name="tomcat.start" depends="setupTomcatTasks" description="Start a deployed webapp using Tomcat manager">
193         <tomcatStart url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${distname}"/>
194     </target>
195
196     <target name="tomcat.stop" depends="setupTomcatTasks" description="Stop a deployed webapp using Tomcat manager">
197         <tomcatStop url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${distname}"/>
198     </target>
199
200     <target name="tomcat.deploy" depends="setupTomcatTasks" description="Upload and deploy using Tomcat manager">
201         <tomcatDeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${distname}"
202                 war="file:${basedir}/${dist}/${distname}.war"/>
203     </target>
204
205     <target name="tomcat.undeploy" depends="setupTomcatTasks" description="Undeploy using Tomcat manager">
206         <tomcatUndeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${distname}"/>
207     </target>
208         
209     
210     <!-- Automated key generation -->
211         <target name="genSecret" depends="compile">
212         <taskdef name="genSecret" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
213                 <genSecret keyStorePath="${appconfig}/handle.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
214         </target>
215
216     <target name="genSalt" depends="compile">
217         <taskdef name="genSalt" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
218         <genSalt keyStorePath="${appconfig}/persistent.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
219     </target>
220         
221         <target name="exampleCertificate">
222                 <genkey alias="tomcat" storepass="exampleorg"
223                         keystore="${tomcat.home}/conf/example.jks"
224                         keyalg="RSA" validity="365"
225                         dname="cn=shibboleth.example.org, o=example.org, c=US"
226                 />
227         </target>
228         
229         
230     <!-- Install Shibboleth -->
231     <target name="install" depends="init, install.init" description="Install Shibboleth">
232
233         <if>
234             <xinput type="confirm" defaultvalue="y">Do you want to install the Shibboleth Identity Provider?</xinput>
235             <then>
236                 <antcall target="install.idp" />
237             </then>
238         </if>
239     </target>
240
241         <target name="install.idp" depends="init, install.init">
242         <xinput message="Deploying java web application.  Do you want to install it directly onto the filesystem or use the tomcat manager application?" 
243             addproperty="idp.install-type" type="menu" casesensitive="no">
244             <xoption>filesystem</xoption>
245             <xoption>manager</xoption>
246         </xinput>
247         
248         <antcall target="install.idp.${idp.install-type}" />
249     </target>
250
251     <target name="install.idp.filesystem" depends="init, install.init, build-util">
252         
253         <input message="Enter Shibboleth install directory [default: ${shib.home}]"
254             addproperty="shib.home.input" defaultvalue="${shib.home}" />
255         <var name="shib.home" value="${shib.home.input}" />
256
257         <input message="Enter tomcat home directory [default: ${tomcat.home}]"
258             addproperty="tomcat.home.input" defaultvalue="${tomcat.home}" />
259         <var name="tomcat.home" value="${tomcat.home.input}" />
260         
261         <copy file="${configroot}/idp.xml.dist" tofile="${configroot}/idp.xml" overwrite="true" />
262         <replace file="${configroot}/idp.xml" token="$SHIB_HOME$" value="${shib.home}" />
263         <war warfile="${dist}/${distname}.war" webxml="${configroot}/idp.xml" basedir="${approot}" update="no" />
264         <copy file="${dist}/${distname}.war" tofile="${tomcat.home}/webapps/${distname}.war" />
265
266         <if>
267             <available file="${shib.home}" />
268             <then>
269                 <if>
270                     <xinput type="confirm">The directory `${shib.home}` already exists.  Do you want to overwrite the existing configuration?</xinput>
271                     <then>
272                         <delete dir="${shib.home}/etc" />
273                         <antcall target="install.idp.filesystem.config" />
274                     </then>
275                 </if>
276             </then>
277             <else>
278                 <antcall target="install.idp.filesystem.config" />
279             </else>
280         </if>
281
282         <copy file="lib/shib-util.jar" todir="${shib.home}/lib" />
283         <copy todir="${shib.home}/bin">
284             <fileset dir="bin"/>
285         </copy>
286
287         <antcall target="savePropertyFile" />
288     </target>
289
290         <target name="install.idp.filesystem.config" depends="init, install.init">
291         <mkdir dir="${shib.home}/etc" />
292         <copy todir="${shib.home}/etc" overwrite="true">
293             <fileset dir="${src}/conf" includesfile="conf/idp-conf.include"/>
294         </copy>
295         <replace file="${shib.home}/etc/idp.xml" token="$SHIB_HOME$" value="${shib.home}" />
296     </target>
297
298         <target name="install.idp.manager" depends="init, install.init">
299         <antcall target="setupTomcatTasks" />
300         
301         <input message="Enter local tomcat directory [default: ${tomcat.home}]" addproperty="tomcat.home.input" defaultValue="${tomcat.home}" />
302         <var name="tomcat.home" value="${tomcat.home.input}" />
303         
304         <input message="Enter tomcat url [default: ${tomcat.url}]" addproperty="tomcat.url.input" defaultValue="${tomcat.url}" />
305         <var name="tomcat.url" value="${tomcat.url.input}" />
306         
307         <input message="Enter tomcat username [default: ${tomcat.username}]" addproperty="tomcat.username.input" defaultValue="${tomcat.username}" />
308         <var name="tomcat.username" value="${tomcat.username.input}" />
309         
310         <input message="Enter tomcat password [default: ${tomcat.password}]" addproperty="tomcat.password.input" defaultValue="${tomcat.password}" />
311         <var name="tomcat.password" value="${tomcat.password.input}" />
312         
313         <antcall target="tomcat.deploy" />
314         <antcall target="savePropertyFile" />
315     </target>
316
317     <target name="savePropertyFile">
318         <propertyfile file="build.properties">
319             <entry key="shib.home" value="${shib.home}" />
320             <entry key="tomcat.home" value="${tomcat.home}" />
321             <entry key="tomcat.url" value="${tomcat.url}" />
322             <entry key="tomcat.username" value="${tomcat.username}" />
323             <entry key="tomcat.password" value="${tomcat.password}" />
324         </propertyfile>
325     </target>
326     
327 </project>