Ouch. Commented out the extension build.
[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="distnameWayf" value="shibboleth-wayf" />
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="custom" value="${root}/custom/" />
19         <property name="custom.libs" value="${custom}/lib"/>
20         <property name="custom.webapges" value="${custom}/web"/>
21         <property name="dist" value="${root}/dist/" />
22         <property name="docs" value="${root}/doc/" />
23         <property name="javadocs" value="${docs}/api/" />
24
25         <property name="year" value="2002-2005"/>
26         <property name="copyright" value="Copyright &#169; ${year} UCAID. All Rights Reserved."/>
27
28
29         <!-- antcontrib tasks -->
30         <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${buildlibs}/ant-contrib.jar"/>
31
32         <!-- Import the tasks for building custom extensions -->
33         <import file="${custom}/extension-build.xml"/>
34
35         <!-- Construct the CLASSPATH -->
36         <path id="build.path">
37                 <pathelement path="${classpath}" />
38                 <pathelement location="${build}" />
39                 <fileset dir="${custom}">
40                         <include name="**/*.jar" />
41                 </fileset>
42                 <fileset dir="${endorsed}">
43                         <include name="**/*.jar" />
44                 </fileset>
45                 <fileset dir="${libdir}">
46                         <include name="**/*.jar" />
47                 </fileset>
48                 <fileset dir="${buildlibs}">
49                         <include name="**/*.jar" />
50                 </fileset>
51         </path>
52
53
54         <!-- Prepare directory structure for project build-->
55         <target name="init">
56                 <mkdir dir="${build}" />
57                 <mkdir dir="${dist}" />
58                 <mkdir dir="${custom.libs}"/>
59                 <mkdir dir="${custom.webapges}"/>
60
61                 <if>
62                         <not> <available file="build.properties" /> </not>
63                         <then>
64                                 <copy file="conf/default.build.properties" tofile="build.properties" />
65                         </then>
66                 </if>
67
68                 <property file="build.properties" />
69         </target>
70
71
72         <!-- This target should be run before checking code into the repository -->
73         <target name="pre-checkin" depends="compile, test-all, clean-all" />
74
75
76         <!-- Compile classes and move them to ${build} -->
77         <target name="compile" depends="init"
78                 description="Compile source files">
79                 <!-- Compile the shib code into the build path -->
80                 <javac srcdir="${src}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
81                         <classpath refid="build.path" />
82                 </javac>
83                 <!-- Copy xml schemas to the build path -->
84                 <copy todir="${build}/schemas">
85                         <fileset dir="${src}/schemas"/>
86                 </copy>
87
88                 <!-- Build extensions -->
89                 <antcall target="build-exts">
90                         <param name="exts.dir" value="${custom}"/>
91                 </antcall>
92         </target>
93
94
95         <!-- Generate API docs -->
96         <target name="javadocs">
97                 <mkdir dir="${docs}" />
98                 <mkdir dir="${javadocs}" />
99                 <javadoc packagenames='edu.internet2.middleware.*'
100                         sourcepath='${src}' destdir='${javadocs}'
101                         author='true' version='true'
102                         windowtitle='Shibboleth Java API' doctitle='Shibboleth Java API'
103                         bottom='${copyright}'>
104                         <classpath refid="build.path" />
105                 </javadoc>
106         </target>
107
108
109         <!-- Build command-line utilities -->
110         <target name="build-util" depends="compile">
111                 <jar jarfile="${distlibs}/shib-util.jar" basedir="${build}" />
112         </target>
113
114         <!-- Cleanup after the build, test, and distribution processes -->
115         <target name="clean" depends="clean-all" />
116         <target name="clean-all" depends="clean-build, clean-dist, clean-test, clean-javadocs, clean-util, clean-ext" />
117         <target name="clean-build">
118                 <delete dir="${build}" />
119                 <delete dir="${custom.libs}"/>
120                 <delete dir="${custom.webapges}"/>
121         </target>
122         <target name="clean-test">
123                 <delete>
124                         <fileset dir="${root}">
125                                 <include name="**/TEST*.txt" />
126                         </fileset>
127                 </delete>
128         </target>
129         <target name="clean-dist">
130                 <delete dir="${dist}" />
131         </target>
132         <target name="clean-javadocs">
133                 <delete dir="${javadocs}" />
134         </target>
135         <target name="clean-util">
136                 <delete>
137                         <fileset dir="${buildlibs}">
138                                 <include name="shib-util.jar" />
139                         </fileset>
140                 </delete>
141         </target>
142         <!-- For IDE development, run this target first to delete all
143         directories generated by the install process before
144         recreating and reinstalling everything. -->
145         <target name="clean-install" depends="init" 
146                 description="Delete old configuration and Tomcat webapp directories.">
147                 <delete dir="${idp.home}" />
148                 <delete dir="${sp.home}" />
149                 <delete dir="${tomcat.home}/webapps/${idp.webapp.name}" />
150                 <delete dir="${tomcat.home}/webapps/${sp.webapp.name}" />
151         </target>
152
153
154         <!-- Add to the classpath for unit tests -->
155         <path id="test.path">
156                 <path refid="build.path"/>
157                 <pathelement location="${tests}"/>
158         </path>
159
160         <!-- Compile classes needed for unit testing -->
161         <target name="compile-tests" depends="compile">
162                 <javac srcdir="${tests}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
163                         <classpath refid="build.path" />
164                 </javac>
165         </target>
166
167         <!-- Run automated tests on compiled code -->
168         <target name="test-all" depends="test-IdP, test-SP" />
169
170         <target name="test-IdP" depends="compile-tests">
171                 <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
172                         <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
173                         <classpath refid="test.path" />
174                         <formatter type="plain" />
175                         <test name="edu.internet2.middleware.shibboleth.aa.arp.ArpTests" />
176                         <test name="edu.internet2.middleware.shibboleth.aa.attrresolv.ResolverTests" />
177                         <test name="edu.internet2.middleware.shibboleth.common.CredentialsTests" />
178                         <test name="edu.internet2.middleware.shibboleth.common.provider.NameMapperTests" />
179                         <test name="edu.internet2.middleware.shibboleth.common.TrustTests" />
180                         <test name="edu.internet2.middleware.shibboleth.idp.provider.DNHostNameExtractionTests" />
181                         <test name="edu.internet2.middleware.shibboleth.metadata.MetadataTests" />
182                 </junit>
183         </target>
184
185         <target name="test-SP" depends="compile-tests">
186                 <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
187                         <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
188                         <classpath refid="test.path" />
189                         <formatter type="plain" />
190                         <test name="edu.internet2.middleware.shibboleth.aap.AAPTests" />
191                 </junit>
192         </target>
193
194
195         <!-- Tomcat Management -->
196         <target name="setupTomcatTasks">
197                 <path id="tomcat.classpath">
198                         <fileset dir="${tomcat.home}/server/lib" includes="catalina-ant.jar"/>
199                 </path>
200
201                 <taskdef name="tomcatStart" classname="org.apache.catalina.ant.StartTask" classpathref="tomcat.classpath"/>
202                 <taskdef name="tomcatStop" classname="org.apache.catalina.ant.StopTask" classpathref="tomcat.classpath"/>
203                 <taskdef name="tomcatDeploy" classname="org.apache.catalina.ant.DeployTask" classpathref="tomcat.classpath"/>
204                 <taskdef name="tomcatUndeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="tomcat.classpath"/>
205         </target>
206
207         <target name="tomcat.start" depends="setupTomcatTasks" description="Start a deployed webapp using Tomcat manager">
208                 <tomcatStart url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
209         </target>
210
211         <target name="tomcat.stop" depends="setupTomcatTasks" description="Stop a deployed webapp using Tomcat manager">
212                 <tomcatStop url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
213         </target>
214
215         <target name="tomcat.deploy" depends="setupTomcatTasks" description="Upload and deploy using Tomcat manager">
216                 <tomcatDeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"
217                         war="file:${basedir}/${dist}/${idp.webapp.name}.war"/>
218         </target>
219
220         <target name="tomcat.undeploy" depends="setupTomcatTasks" description="Undeploy using Tomcat manager">
221                 <tomcatUndeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
222         </target>
223
224
225         <!-- Automated key generation for crypto handles -->
226         <target name="genSecret" depends="compile">
227                 <taskdef name="genSecret" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
228                 <genSecret keyStorePath="${appconfig}/handle.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
229         </target>
230
231
232         <!-- Generate salt for use with targetted id -->
233         <target name="genSalt" depends="compile">
234                 <taskdef name="genSalt" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
235                 <genSalt keyStorePath="${appconfig}/persistent.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
236         </target>
237
238         <target name="exampleCertificates">
239                 <!--
240                 This target provides an example of the generation of
241                 self-signed Certificates for the IdP and SP. You may
242                 change the cn= and use it to generate new identities
243                 when you want to replace "example.org" with your real
244                 organization dns. However,the generated key and 
245                 certificate also have to be defined to the Credentials
246                 of the IdP and SP config files and added to the Metadata.
247                 -->
248                 <genkey alias="tomcat" storepass="exampleorg"
249                         keystore="${tomcat.home}/conf/idp-example.jks"
250                         keyalg="RSA" validity="365"
251                         dname="cn=idp.example.org, o=example.org, c=US"
252                         />
253                 <genkey alias="tomcat" storepass="exampleorg"
254                         keystore="${tomcat.home}/conf/sp-example.jks"
255                         keyalg="RSA" validity="365"
256                         dname="cn=sp.example.org, o=example.org, c=US"
257                         />
258         </target>
259
260
261         <!-- Package Shibboleth -->
262         <target name="package-idp" depends="compile, install.url" description="Creates the IdP war file and moves it to ${dist}">
263                 <!-- copy values to deployment descriptor -->
264                 <copy file="${configroot}/${idp.deployment.descriptor}" tofile="${configroot}/idp.xml" overwrite="true" />
265                 <replace file="${configroot}/idp.xml" token="$IDP_HOME$" value="${idp.home.url}" />
266
267                 <!-- create the war -->
268                 <war warfile="${dist}/${idp.webapp.name}.war" webxml="${configroot}/idp.xml" basedir="${approot}" update="no">
269                         <!-- Grab any custom extension libraries -->
270                         <lib dir="${custom.libs}"/>
271
272                         <!-- Grab any web material from custom extensions -->
273                         <fileset dir="${custom.webapges}"/>
274                 </war>
275
276                 <!-- clean up generated descriptor -->
277                 <delete file="${configroot}/idp.xml"/>
278         </target>
279
280         <target name="package-wayf" depends="compile" description="Creates the WAYF war and moves it to ${dist}">
281                 <war warfile="${dist}/${distnameWayf}.war" webxml="${configroot}/wayf.xml" basedir="${approot}" update="no" />
282         </target>
283
284         <target name="package-sp" depends="compile, install.url" description="Creates the Java SP war and moves it to ${dist}">
285                 <!-- copy values to deployment descriptor -->
286                 <copy file="${configroot}/${sp.deployment.descriptor}" tofile="${configroot}/sp.xml" overwrite="true" />
287                 <replace file="${configroot}/sp.xml" token="$SP_HOME$" value="${sp.home.url}" />
288
289                 <!-- create the war -->
290                 <war warfile="${dist}/${sp.webapp.name}.war" webxml="${configroot}/sp.xml" basedir="${approot}" update="no">
291                         <!-- Grab any custom extension libraries -->
292                         <lib dir="${custom.libs}"/>
293
294                         <!-- Grab any web material from custom extensions -->
295                         <fileset dir="${custom.webapges}"/>
296                 </war>
297
298                 <!-- clean up generated descriptor -->
299                 <delete file="${configroot}/sp.xml"/>
300         </target>
301
302
303         <!-- Install Shibboleth -->
304         <target name="install.init">
305                 <taskdef name="xinput" classname="edu.internet2.middleware.shibboleth.utils.ant.XInput" classpath="${build}" />
306                 <typedef name="xoption" classname="edu.internet2.middleware.shibboleth.utils.ant.XInputOption" classpath="${build}" />
307         </target>
308
309         <target name="install.url">
310                 <taskdef name="urlconvert" classname="edu.internet2.middleware.shibboleth.utils.ant.URLConvert" classpath="${build}"/>
311                 <urlconvert path="${idp.home}" addProperty="idp.home.url"/>
312                 <urlconvert path="${sp.home}" addProperty="sp.home.url"/>
313         </target>
314
315         <target name="install" depends="init, install.init" description="Install Shibboleth">
316                 <if>
317                         <xinput type="confirm" defaultvalue="y">Do you want to install the Shibboleth Identity Provider?</xinput>
318                         <then>
319                                 <input message="What name do you want to use for the Identity Provider web application? [default: ${idp.webapp.name}]" 
320                                         addproperty="idp.webapp.name.input" defaultValue="${idp.webapp.name}" />
321                                 <var name="idp.webapp.name" value="${idp.webapp.name.input}" />
322
323                                 <antcall target="install.idp" />
324                         </then>
325                 </if>
326         </target>
327
328         <target name="install.idp" depends="init, install.init">
329                 <xinput message="Deploying the java web application.  Do you want to install it directly onto the filesystem or use the tomcat manager application?" 
330                         addproperty="idp.install-type.input" type="menu" casesensitive="no" defaultValue="${idp.install-type}">
331                         <xoption value="filesystem.prompt">filesystem</xoption>
332                         <xoption>manager</xoption>
333                 </xinput>
334                 <var name="idp.install-type" value="${idp.install-type.input}" />
335
336                 <antcall target="install.idp.${idp.install-type}" />
337         </target>
338
339         <!-- Prompt user for filesystem installation options and save them to build.properties -->
340         <target name="install.idp.filesystem.prompt" depends="init, install.init">
341                 <input message="Select an installation base for the Shibboleth Identity Provider [default: ${idp.home}]"
342                         addproperty="idp.home.input" defaultvalue="${idp.home}" />
343                 <var name="idp.home" value="${idp.home.input}" />
344                 <input message="Enter tomcat home directory [default: ${tomcat.home}]"
345                         addproperty="tomcat.home.input" defaultvalue="${tomcat.home}" />
346                 <var name="tomcat.home" value="${tomcat.home.input}" />
347
348                 <if>
349                         <available file="${idp.home}/etc" />
350                         <then>
351                                 <xinput type="confirm" addproperty="copy-idp-conf1">The directory `${idp.home}${file.separator}etc` already exists.  Do you want to overwrite the existing configuration?</xinput>
352                                 <if>
353                                         <equals arg1="${copy-idp-conf1}" arg2="y" />
354                                         <then>
355                                                 <xinput type="confirm" addproperty="copy-idp-conf">WARNING!!! You are about to delete your Shibboleth IdP configuration.  Are you certain you certain this is what you want?</xinput>
356                                         </then>
357                                 </if>
358                         </then>
359                         <else>
360                                 <property name="copy-idp-conf" value="y" />
361                         </else>
362                 </if>
363
364                 <antcall target="install.idp.filesystem" />
365                 <antcall target="savePropertyFile" />
366         </target>
367
368         <!-- Install Shibboleth IdP to filesystem using the properties in build.properties -->
369         <target name="install.idp.filesystem" depends="init, install.init, build-util, install.url, package-idp" 
370                 description="Install Shibboleth IdP to filesystem using the properties in build.properties">
371
372                 <!-- Move IdP war to Tomcat deployment directory -->
373                 <copy file="${dist}/${idp.webapp.name}.war" tofile="${tomcat.home}/webapps/${idp.webapp.name}.war" />
374
375                 <!-- copy IdP jars and utilities -->
376                 <copy todir="${idp.home}/lib">
377                         <fileset dir="lib" includesfile="conf/idp-lib.include" />
378                 </copy>
379
380                 <copy todir="${idp.home}/bin">
381                         <fileset dir="bin"/>
382                 </copy>
383                 <chmod dir="${idp.home}/bin" perm="ug+rx" includes="**/*"/>
384
385                 <mkdir dir="${idp.home}/logs" />
386
387                 <!-- copy IdP configuration -->
388                 <if>
389                         <or>
390                                 <equals arg1="${copy-idp-conf}" arg2="y" />
391                                 <not> <available file="${idp.home}/etc" /> </not>
392                         </or>
393                         <then>
394                                 <delete dir="${idp.home}/etc" />
395                                 <antcall target="install.idp.filesystem.config" />
396                         </then>
397                 </if>
398         </target>
399
400         <!-- Install Shibboleth SP to filesystem using the properties in build.properties -->
401         <target name="install.sp.filesystem" depends="init, install.init, build-util, install.url, package-sp" 
402                 description="Install Shibboleth SP to filesystem using the properties in build.properties">
403
404                 <!-- Move SP war to Tomcat deployment directory -->
405                 <copy file="${dist}/${sp.webapp.name}.war" tofile="${tomcat.home}/webapps/${sp.webapp.name}.war" />
406
407                 <!-- copy sp jars and utilities -->
408                 <copy todir="${sp.home}/lib">
409                         <fileset dir="lib" includesfile="conf/idp-lib.include" />
410                 </copy>
411
412                 <copy todir="${sp.home}/bin">
413                         <fileset dir="bin"/>
414                 </copy>
415                 <chmod dir="${sp.home}/bin" perm="ug+rx" includes="**/*"/>
416
417                 <mkdir dir="${sp.home}/logs" />
418
419                 <!-- copy sp configuration -->
420                 <if>
421                         <or>
422                                 <equals arg1="${copy-sp-conf}" arg2="y" />
423                                 <not> <available file="${sp.home}/etc" /> </not>
424                         </or>
425                         <then>
426                                 <delete dir="${sp.home}/etc" />
427                                 <antcall target="install.sp.filesystem.config" />
428                         </then>
429                 </if>
430         </target>
431
432
433         <!-- copy shibboleth configuration to $IDP_HOME/etc, overwriting any existing configuration -->
434         <target name="install.idp.filesystem.config" depends="init, install.init, install.url">
435                 <mkdir dir="${idp.home}/etc" />
436                 <copy todir="${idp.home}/etc" overwrite="true">
437                         <fileset dir="${src}/conf" includesfile="conf/idp-conf.include"/>
438                 </copy>
439                 <move file="${idp.home}/etc/dist.idp.xml" tofile="${idp.home}/etc/idp.xml" overwrite="true" />
440                 <replace file="${idp.home}/etc/idp.xml" token="$IDP_HOME$" value="${idp.home.url}" />
441                 <replace file="${idp.home}/etc/idp.xml" token="$IDP_WEBAPP_NAME$" value="${idp.webapp.name}" />
442         </target>
443
444         <!-- copy SP configuration to $SP_HOME$/etc, overwriting any existing configuration -->
445         <target name="install.sp.filesystem.config" depends="init, install.init">
446                 <mkdir dir="${sp.home}/etc" />
447                 <copy todir="${sp.home}/etc" overwrite="true">
448                         <fileset dir="${src}/conf" includesfile="conf/sp-conf.include"/>
449                 </copy>
450                 <move file="${sp.home}/etc/dist.sp.xml" tofile="${sp.home}/etc/sp.xml" overwrite="true" />
451                 <replace file="${sp.home}/etc/sp.xml" token="$SP_HOME$" value="${sp.home.url}" />
452         </target>
453
454         <!-- install Shibboleth-IdP war using tomcat's manager app -->
455         <target name="install.idp.manager" depends="init, install.init">
456                 <antcall target="setupTomcatTasks" />
457
458                 <input message="Enter local tomcat directory [default: ${tomcat.home}]" addproperty="tomcat.home.input" defaultValue="${tomcat.home}" />
459                 <var name="tomcat.home" value="${tomcat.home.input}" />
460
461                 <input message="Enter tomcat url [default: ${tomcat.url}]" addproperty="tomcat.url.input" defaultValue="${tomcat.url}" />
462                 <var name="tomcat.url" value="${tomcat.url.input}" />
463
464                 <input message="Enter tomcat username [default: ${tomcat.username}]" addproperty="tomcat.username.input" defaultValue="${tomcat.username}" />
465                 <var name="tomcat.username" value="${tomcat.username.input}" />
466
467                 <input message="Enter tomcat password [default: ${tomcat.password}]" addproperty="tomcat.password.input" defaultValue="${tomcat.password}" />
468                 <var name="tomcat.password" value="${tomcat.password.input}" />
469
470                 <antcall target="tomcat.deploy" />
471                 <antcall target="savePropertyFile" />
472         </target>
473
474         <!-- save configuration to build.properties -->
475         <target name="savePropertyFile">
476                 <propertyfile file="build.properties">
477                         <entry key="idp.home" value="${idp.home}" />
478                         <entry key="sp.home" value="${sp.home}" />
479                         <entry key="idp.webapp.name" value="${idp.webapp.name}" />
480                         <entry key="sp.webapp.name" value="${sp.webapp.name}" />
481                         <entry key="idp.install-type" value="${idp.install-type}" />
482                         <entry key="tomcat.home" value="${tomcat.home}" />
483                         <entry key="tomcat.url" value="${tomcat.url}" />
484                         <entry key="tomcat.username" value="${tomcat.username}" />
485                         <entry key="tomcat.password" value="${tomcat.password}" />
486                 </propertyfile>
487         </target>
488 </project>