1 <!-- Main build configutaion for Shibboleth java components - Walter Hoehn 06/04/2002 -->
3 <project name="Shibboleth" default="install" basedir=".">
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/" />
25 <property name="year" value="2002-2005"/>
26 <property name="copyright" value="Copyright © ${year} UCAID. All Rights Reserved."/>
28 <!-- antcontrib tasks -->
29 <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${buildlibs}/ant-contrib.jar"/>
31 <!-- Import the tasks for building custom extensions -->
32 <import file="${custom}/extension-build.xml"/>
35 <!-- Construct the CLASSPATH -->
36 <path id="build.path">
37 <pathelement location="${build}" />
38 <fileset dir="${endorsed}" includes="**/*.jar" />
39 <fileset dir="${libdir}" includes="**/*.jar" />
40 <fileset dir="${buildlibs}" includes="**/*.jar" />
44 <!-- Add to the classpath for unit tests -->
46 <path refid="build.path"/>
47 <pathelement location="${tests}"/>
51 <!-- Prepare directory structure for project build-->
53 <mkdir dir="${build}" />
54 <mkdir dir="${dist}" />
55 <mkdir dir="${custom.libs}"/>
56 <mkdir dir="${custom.webapges}"/>
59 <not> <available file="build.properties" /> </not>
61 <copy file="conf/default.build.properties" tofile="build.properties" />
65 <property file="build.properties" />
69 <!-- This target should be run before checking code into the repository -->
70 <target name="pre-checkin" depends="compile, test, clean-all" />
73 <!-- Compile classes and move them to ${build} -->
74 <target name="compile" depends="init"
75 description="Compile source files">
76 <!-- Compile the shib code into the build path -->
77 <javac srcdir="${src}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
78 <classpath refid="build.path" />
80 <!-- Copy xml schemas to the build path -->
81 <copy todir="${build}/schemas">
82 <fileset dir="${src}/schemas"/>
85 <!-- Build extensions -->
86 <antcall target="ext-invoke">
87 <param name="exts.dir" value="${custom}"/>
88 <param name="ext.build.function" value="ext-build"/>
93 <!-- Generate API docs -->
94 <target name="javadocs">
95 <mkdir dir="${docs}" />
96 <mkdir dir="${javadocs}" />
97 <javadoc packagenames='edu.internet2.middleware.*'
98 sourcepath='${src}' destdir='${javadocs}'
99 author='true' version='true'
100 windowtitle='Shibboleth Java API' doctitle='Shibboleth Java API'
101 bottom='${copyright}'>
102 <classpath refid="build.path" />
107 <!-- Build command-line utilities -->
108 <target name="build-util" depends="compile">
109 <jar jarfile="${distlibs}/shib-util.jar" basedir="${build}" />
113 <!-- Compile classes needed for unit testing -->
114 <target name="compile-tests" depends="compile">
115 <javac srcdir="${tests}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
116 <classpath refid="build.path" />
120 <target name="test" depends="compile-tests">
121 <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
122 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
124 <fileset dir="${custom.libs}">
125 <include name="*.jar"/>
127 <path refid="test.path"/>
129 <formatter type="plain" />
130 <test name="edu.internet2.middleware.shibboleth.aa.arp.ArpTests" />
131 <test name="edu.internet2.middleware.shibboleth.aa.attrresolv.ResolverTests" />
132 <test name="edu.internet2.middleware.shibboleth.common.CredentialsTests" />
133 <test name="edu.internet2.middleware.shibboleth.common.provider.NameMapperTests" />
134 <test name="edu.internet2.middleware.shibboleth.common.TrustTests" />
135 <test name="edu.internet2.middleware.shibboleth.idp.provider.DNHostNameExtractionTests" />
136 <test name="edu.internet2.middleware.shibboleth.metadata.MetadataTests" />
137 <test name="edu.internet2.middleware.shibboleth.idp.SSOTest" />
138 <test name="edu.internet2.middleware.shibboleth.idp.AATest" />
143 <!-- Tomcat Management -->
144 <target name="setupTomcatTasks" depends="init">
145 <path id="tomcat.classpath">
146 <fileset dir="${tomcat.home}/server/lib" includes="catalina-ant.jar"/>
149 <taskdef name="tomcatStart" classname="org.apache.catalina.ant.StartTask" classpathref="tomcat.classpath"/>
150 <taskdef name="tomcatStop" classname="org.apache.catalina.ant.StopTask" classpathref="tomcat.classpath"/>
151 <taskdef name="tomcatDeploy" classname="org.apache.catalina.ant.DeployTask" classpathref="tomcat.classpath"/>
152 <taskdef name="tomcatUndeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="tomcat.classpath"/>
155 <target name="tomcat.start" depends="setupTomcatTasks" description="Start a deployed webapp using Tomcat manager">
156 <tomcatStart url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
159 <target name="tomcat.stop" depends="setupTomcatTasks" description="Stop a deployed webapp using Tomcat manager">
160 <tomcatStop url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
163 <target name="tomcat.deploy" depends="setupTomcatTasks" description="Upload and deploy using Tomcat manager">
164 <tomcatDeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"
165 war="file:${basedir}/${dist}/${idp.webapp.name}.war"/>
168 <target name="tomcat.undeploy" depends="setupTomcatTasks" description="Undeploy using Tomcat manager">
169 <tomcatUndeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${idp.webapp.name}"/>
173 <!-- Automated key generation for crypto handles -->
174 <target name="genSecret" depends="compile">
175 <taskdef name="genSecret" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
176 <genSecret keyStorePath="${appconfig}/handle.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
180 <!-- Generate salt for use with targetted id -->
181 <target name="genSalt" depends="compile">
182 <taskdef name="genSalt" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
183 <genSalt keyStorePath="${appconfig}/persistent.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
186 <target name="exampleCertificates">
188 This target provides an example of the generation of
189 self-signed Certificates for the IdP. You may
190 change the cn= and use it to generate new identities
191 when you want to replace "example.org" with your real
192 organization dns. However,the generated key and
193 certificate also have to be defined to the Credentials
194 of the IdP config files and added to the Metadata.
196 <genkey alias="tomcat" storepass="exampleorg"
197 keystore="${tomcat.home}/conf/idp-example.jks"
198 keyalg="RSA" validity="365"
199 dname="cn=idp.example.org, o=example.org, c=US"
204 <!-- Package Shibboleth -->
205 <target name="package-idp" depends="compile, install.url" description="Creates the IdP war file and moves it to ${dist}">
206 <!-- copy values to deployment descriptor -->
207 <copy file="${configroot}/${idp.deployment.descriptor}" tofile="${configroot}/idp.xml" overwrite="true" />
208 <replace file="${configroot}/idp.xml" token="$IDP_HOME$" value="${idp.home.url}" />
210 <!-- package extensions -->
211 <antcall target="ext-invoke">
212 <param name="exts.dir" value="${custom}"/>
213 <param name="ext.build.function" value="ext-package"/>
214 <param name="ext.filesystem.home" value="${idp.home}"/>
215 <param name="ext.home.token" value="$IDP_HOME$"/>
218 <!-- create the war -->
219 <war warfile="${dist}/${idp.webapp.name}.war" webxml="${configroot}/idp.xml" basedir="${approot}" update="no" duplicate="preserve">
220 <!-- Grab any custom extension libraries -->
221 <lib dir="${custom.libs}"/>
223 <!-- Grab any web material from custom extensions -->
224 <fileset dir="${custom.webapges}"/>
227 <!-- clean up generated descriptor -->
228 <delete file="${configroot}/idp.xml"/>
231 <!-- Install Shibboleth -->
232 <target name="install.init">
233 <taskdef name="xinput" classname="edu.internet2.middleware.ant.XInput" classpath="${build}" />
234 <typedef name="xoption" classname="edu.internet2.middleware.ant.XInputOption" classpath="${build}" />
237 <target name="install.url">
238 <taskdef name="urlconvert" classname="edu.internet2.middleware.ant.URLConvert" classpath="${build}"/>
241 <target name="install" depends="init, install.init" description="Install Shibboleth">
243 <xinput type="confirm" defaultvalue="y">Do you want to install the Shibboleth Identity Provider?</xinput>
245 <input message="What name do you want to use for the Identity Provider web application? [default: ${idp.webapp.name}]"
246 addproperty="idp.webapp.name.input" defaultValue="${idp.webapp.name}" />
247 <var name="idp.webapp.name" value="${idp.webapp.name.input}" />
249 <antcall target="install.idp" />
254 <target name="install.idp" depends="init, install.init">
255 <xinput message="Deploying the java web application. Do you want to install it directly onto the filesystem or use the tomcat manager application?"
256 addproperty="idp.install-type.input" type="menu" casesensitive="no" defaultValue="${idp.install-type}">
257 <xoption value="filesystem.prompt">filesystem</xoption>
258 <xoption>manager</xoption>
260 <var name="idp.install-type" value="${idp.install-type.input}" />
262 <antcall target="install.idp.${idp.install-type}" />
265 <!-- Prompt user for filesystem installation options and save them to build.properties -->
266 <target name="install.idp.filesystem.prompt" depends="init, install.init">
267 <input message="Select a home directory for the Shibboleth Identity Provider [default: ${idp.home}]"
268 addproperty="idp.home.input" defaultvalue="${idp.home}" />
269 <var name="idp.home" value="${idp.home.input}" />
270 <input message="Enter tomcat home directory [default: ${tomcat.home}]"
271 addproperty="tomcat.home.input" defaultvalue="${tomcat.home}" />
272 <var name="tomcat.home" value="${tomcat.home.input}" />
275 <available file="${idp.home}/etc" />
277 <echo>--------------------------------------------------------------------------------------</echo>
279 <echo>--- NOTE: Existing Identiity Provider configuration at ${idp.home}/etc ${line.separator}--- will not be overwritten.</echo>
281 <echo>--------------------------------------------------------------------------------------</echo>
282 <property name="copy-idp-conf" value="n" />
285 <property name="copy-idp-conf" value="y" />
289 <antcall target="install.idp.filesystem" />
290 <antcall target="savePropertyFile" />
293 <!-- Install Shibboleth IdP to filesystem using the properties in build.properties -->
294 <target name="install.idp.filesystem" depends="init, install.init, build-util, install.url, package-idp"
295 description="Install Shibboleth IdP to filesystem using the properties in build.properties">
297 <!-- Move IdP war to Tomcat deployment directory -->
298 <copy file="${dist}/${idp.webapp.name}.war" tofile="${tomcat.home}/webapps/${idp.webapp.name}.war" />
300 <!-- copy IdP jars and utilities -->
301 <copy todir="${idp.home}/lib">
302 <fileset dir="lib" includesfile="conf/idp-lib.include" />
305 <copy todir="${idp.home}/endorsed">
306 <fileset dir="endorsed" />
309 <copy todir="${idp.home}/bin">
312 <chmod dir="${idp.home}/bin" perm="ug+rx" includes="**/*"/>
314 <mkdir dir="${idp.home}/logs" />
316 <!-- Copy necessary files to IDP_HOME -->
317 <antcall target="install.idp.buildHome" />
319 <antcall target="ext-invoke">
320 <param name="exts.dir" value="${custom}"/>
321 <param name="ext.build.function" value="ext-install-filesystem"/>
322 <param name="ext.filesystem.home" value="${idp.home}"/>
323 <param name="ext.home.token" value="$IDP_HOME$"/>
328 <target name="install.idp.buildHome" depends="init, install.init">
329 <!-- copy IdP configuration -->
332 <equals arg1="${copy-idp-conf}" arg2="y" />
333 <not> <available file="${idp.home}/etc" /> </not>
336 <delete dir="${idp.home}/etc" />
337 <antcall target="install.idp.filesystem.config" />
342 <!-- copy shibboleth configuration to $IDP_HOME/etc, overwriting any existing configuration -->
343 <target name="install.idp.filesystem.config" depends="init, install.init, install.url">
344 <mkdir dir="${idp.home}/etc" />
345 <copy todir="${idp.home}/etc" overwrite="true">
346 <fileset dir="${src}/conf" includesfile="conf/idp-conf.include"/>
348 <move file="${idp.home}/etc/dist.idp.xml" tofile="${idp.home}/etc/idp.xml" overwrite="true" />
349 <replace file="${idp.home}/etc/idp.xml" token="$IDP_HOME$" value="${idp.home.url}" />
350 <replace file="${idp.home}/etc/idp.xml" token="$IDP_WEBAPP_NAME$" value="${idp.webapp.name}" />
353 <!-- install Shibboleth-IdP war using tomcat's manager app -->
354 <target name="install.idp.manager" depends="init, install.init">
355 <antcall target="setupTomcatTasks" />
357 <input message="Enter local tomcat directory [default: ${tomcat.home}]" addproperty="tomcat.home.input" defaultValue="${tomcat.home}" />
358 <var name="tomcat.home" value="${tomcat.home.input}" />
360 <input message="Enter tomcat url [default: ${tomcat.url}]" addproperty="tomcat.url.input" defaultValue="${tomcat.url}" />
361 <var name="tomcat.url" value="${tomcat.url.input}" />
363 <input message="Enter tomcat username [default: ${tomcat.username}]" addproperty="tomcat.username.input" defaultValue="${tomcat.username}" />
364 <var name="tomcat.username" value="${tomcat.username.input}" />
366 <input message="Enter tomcat password [default: ${tomcat.password}]" addproperty="tomcat.password.input" defaultValue="${tomcat.password}" />
367 <var name="tomcat.password" value="${tomcat.password.input}" />
369 <antcall target="package-idp" />
370 <antcall target="tomcat.deploy" />
371 <antcall target="install.idp.buildHome" />
372 <antcall target="savePropertyFile" />
375 <!-- save configuration to build.properties -->
376 <target name="savePropertyFile">
377 <propertyfile file="build.properties">
378 <entry key="idp.home" value="${idp.home}" />
379 <entry key="idp.webapp.name" value="${idp.webapp.name}" />
380 <entry key="idp.install-type" value="${idp.install-type}" />
381 <entry key="tomcat.home" value="${tomcat.home}" />
382 <entry key="tomcat.url" value="${tomcat.url}" />
383 <entry key="tomcat.username" value="${tomcat.username}" />
384 <entry key="tomcat.password" value="${tomcat.password}" />
389 <!-- Cleanup after the build, test, and distribution processes -->
390 <target name="clean" depends="clean-all" />
392 <target name="clean-all" depends="clean-build, clean-dist, clean-test, clean-javadocs, clean-util"/>
394 <target name="clean-build">
395 <delete dir="${build}" />
396 <delete dir="${custom.libs}"/>
397 <delete dir="${custom.webapges}"/>
398 <antcall target="ext-invoke">
399 <param name="exts.dir" value="${custom}"/>
400 <param name="ext.build.function" value="ext-clean-build"/>
404 <target name="clean-test">
406 <fileset dir="${root}">
407 <include name="**/TEST*.txt" />
412 <target name="clean-dist">
413 <delete dir="${dist}" />
414 <antcall target="ext-invoke">
415 <param name="exts.dir" value="${custom}"/>
416 <param name="ext.build.function" value="ext-clean-dist"/>
420 <target name="clean-javadocs">
421 <delete dir="${javadocs}" />
422 <antcall target="ext-invoke">
423 <param name="exts.dir" value="${custom}"/>
424 <param name="ext.build.function" value="ext-clean-javadocs"/>
428 <target name="clean-util">
430 <fileset dir="${buildlibs}">
431 <include name="shib-util.jar" />
436 <!-- For IDE development, run this target first to delete all
437 directories generated by the install process before
438 recreating and reinstalling everything. -->
439 <target name="clean-install" depends="init"
440 description="Delete old configuration and Tomcat webapp directories.">
441 <delete dir="${idp.home}" />
442 <delete dir="${tomcat.home}/webapps/${idp.webapp.name}" />