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="distname" value="shibboleth-idp" />
7 <property name="distnameWayf" value="shibboleth-wayf" />
8 <property name="root" value="." />
9 <property name="src" value="${root}/src/" />
10 <property name="tests" value="${root}/tests/" />
11 <property name="approot" value="${root}/webApplication/" />
12 <property name="appconfig" value="${src}/conf/" />
13 <property name="configroot" value="${root}/webAppConfig/" />
14 <property name="build" value="${approot}/WEB-INF/classes/" />
15 <property name="libdir" value="${approot}/WEB-INF/lib/" />
16 <property name="buildlibs" value="${root}/lib/" />
17 <property name="endorsed" value="${root}/endorsed/" />
18 <property name="distlibs" value="${root}/lib/" />
19 <property name="custom" value="${root}/custom/" />
20 <property name="dist" value="${root}/dist/" />
21 <property name="docs" value="${root}/doc/" />
22 <property name="javadocs" value="${docs}/api/" />
24 <property name="year" value="2002-2005"/>
25 <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"/>
32 <!-- Construct the CLASSPATH -->
33 <path id="build.path">
34 <pathelement path="${classpath}" />
35 <pathelement location="${build}" />
36 <fileset dir="${custom}">
37 <include name="**/*.jar" />
39 <fileset dir="${endorsed}">
40 <include name="**/*.jar" />
42 <fileset dir="${libdir}">
43 <include name="**/*.jar" />
45 <fileset dir="${buildlibs}">
46 <include name="**/*.jar" />
51 <!-- Prepare directory structure for project build-->
53 <mkdir dir="${build}" />
54 <mkdir dir="${dist}" />
55 <property file="build.properties" />
59 <!-- This target should be run before checking code into the repository -->
60 <target name="pre-checkin" depends="compile, test-all, clean-all" />
63 <!-- Compile classes and move them to ${build} -->
64 <target name="compile" depends="init"
65 description="Compile source files">
66 <!-- Compile the shib code into the build path -->
67 <javac srcdir="${src}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
68 <classpath refid="build.path" />
70 <!-- Compile site-specific code into the build path -->
71 <javac srcdir="${custom}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
72 <classpath refid="build.path" />
74 <!-- Copy xml schemas to the build path -->
75 <copy todir="${build}/schemas">
76 <fileset dir="${src}/schemas"/>
78 <!-- Copy any site-specific jars to the build path -->
79 <copy todir="${libdir}">
80 <fileset dir="${custom}" includes="**/*.jar" />
85 <!-- Generate API docs -->
86 <target name="javadocs">
87 <mkdir dir="${docs}" />
88 <mkdir dir="${javadocs}" />
89 <javadoc packagenames='edu.internet2.middleware.*'
90 sourcepath='${src}' destdir='${javadocs}'
91 author='true' version='true'
92 windowtitle='Shibboleth Java API' doctitle='Shibboleth Java API'
93 bottom='${copyright}'>
94 <classpath refid="build.path" />
99 <!-- Build command-line utilities -->
100 <target name="build-util" depends="compile">
101 <jar jarfile="${distlibs}/shib-util.jar" basedir="${build}" />
105 <!-- Cleanup after the build, test, and distribution processes -->
106 <target name="clean" depends="clean-all" />
107 <target name="clean-all" depends="clean-build, clean-dist, clean-test, clean-javadocs, clean-util" />
108 <target name="clean-build">
109 <delete dir="${build}" />
111 <target name="clean-test">
113 <fileset dir="${root}">
114 <include name="**/TEST*.txt" />
118 <target name="clean-dist">
119 <delete dir="${dist}" />
121 <target name="clean-javadocs">
122 <delete dir="${javadocs}" />
124 <target name="clean-util">
126 <fileset dir="${buildlibs}">
127 <include name="shib-util.jar" />
133 <!-- Add to the classpath for unit tests -->
134 <path id="test.path">
135 <path refid="build.path"/>
136 <pathelement location="${tests}"/>
139 <!-- Compile classes needed for unit testing -->
140 <target name="compile-tests" depends="compile">
141 <javac srcdir="${tests}" destdir="${build}" includes="**/*.java" debug="on" source="1.4">
142 <classpath refid="build.path" />
146 <!-- Run automated tests on compiled code -->
147 <target name="test-all" depends="test-IdP, test-SP" />
149 <target name="test-IdP" depends="compile-tests">
150 <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
151 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
152 <classpath refid="test.path" />
153 <formatter type="plain" />
154 <test name="edu.internet2.middleware.shibboleth.aa.arp.ArpTests" />
155 <test name="edu.internet2.middleware.shibboleth.aa.attrresolv.ResolverTests" />
156 <test name="edu.internet2.middleware.shibboleth.common.CredentialsTests" />
157 <test name="edu.internet2.middleware.shibboleth.common.provider.NameMapperTests" />
158 <test name="edu.internet2.middleware.shibboleth.common.TrustTests" />
159 <test name="edu.internet2.middleware.shibboleth.idp.provider.DNHostNameExtractionTests" />
160 <test name="edu.internet2.middleware.shibboleth.metadata.MetadataTests" />
164 <target name="test-SP" depends="compile-tests">
165 <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
166 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
167 <classpath refid="test.path" />
168 <formatter type="plain" />
169 <test name="edu.internet2.middleware.shibboleth.aap.AAPTests" />
174 <!-- Tomcat Management -->
175 <target name="setupTomcatTasks">
176 <path id="tomcat.classpath">
177 <fileset dir="${tomcat.home}/server/lib" includes="catalina-ant.jar"/>
180 <taskdef name="tomcatStart" classname="org.apache.catalina.ant.StartTask" classpathref="tomcat.classpath"/>
181 <taskdef name="tomcatStop" classname="org.apache.catalina.ant.StopTask" classpathref="tomcat.classpath"/>
182 <taskdef name="tomcatDeploy" classname="org.apache.catalina.ant.DeployTask" classpathref="tomcat.classpath"/>
183 <taskdef name="tomcatUndeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="tomcat.classpath"/>
186 <target name="tomcat.start" depends="setupTomcatTasks" description="Start a deployed webapp using Tomcat manager">
187 <tomcatStart url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${distname}"/>
190 <target name="tomcat.stop" depends="setupTomcatTasks" description="Stop a deployed webapp using Tomcat manager">
191 <tomcatStop url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${distname}"/>
194 <target name="tomcat.deploy" depends="setupTomcatTasks" description="Upload and deploy using Tomcat manager">
195 <tomcatDeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${distname}"
196 war="file:${basedir}/${dist}/${distname}.war"/>
199 <target name="tomcat.undeploy" depends="setupTomcatTasks" description="Undeploy using Tomcat manager">
200 <tomcatUndeploy url="${tomcat.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${distname}"/>
204 <!-- Automated key generation for crypto handles -->
205 <target name="genSecret" depends="compile">
206 <taskdef name="genSecret" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
207 <genSecret keyStorePath="${appconfig}/handle.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
211 <!-- Generate salt for use with targetted id -->
212 <target name="genSalt" depends="compile">
213 <taskdef name="genSalt" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
214 <genSalt keyStorePath="${appconfig}/persistent.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
217 <target name="exampleCertificate">
218 <genkey alias="tomcat" storepass="exampleorg"
219 keystore="${tomcat.home}/conf/example.jks"
220 keyalg="RSA" validity="365"
221 dname="cn=shibboleth.example.org, o=example.org, c=US"
226 <!-- Install Shibboleth -->
227 <target name="install.init">
228 <taskdef name="xinput" classname="edu.internet2.middleware.shibboleth.utils.ant.XInput" classpath="${build}"/>
229 <typedef name="xoption" classname="edu.internet2.middleware.shibboleth.utils.ant.XInputOption" classpath="${build}"/>
232 <target name="install" depends="init, install.init" description="Install Shibboleth">
234 <xinput type="confirm" defaultvalue="y">Do you want to install the Shibboleth Identity Provider?</xinput>
236 <input message="What name do you want to use for the Identity Provider web application? [default: ${shib.webapp.name}]"
237 addproperty="shib.webapp.name.input" defaultValue="${shib.webapp.name}" />
238 <var name="shib.webapp.name" value="${shib.webapp.name.input}" />
240 <antcall target="install.idp" />
245 <target name="install.idp" depends="init, install.init">
246 <xinput message="Deploying the java web application. Do you want to install it directly onto the filesystem or use the tomcat manager application?"
247 addproperty="idp.install-type.input" type="menu" casesensitive="no" defaultValue="${idp.install-type}">
248 <xoption>filesystem</xoption>
249 <xoption>manager</xoption>
251 <var name="idp.install-type" value="${idp.install-type.input}" />
253 <antcall target="install.idp.${idp.install-type}" />
256 <target name="install.idp.filesystem" depends="init, install.init, build-util">
257 <input message="Select an installation base for the Shibboleth Identity Provider [default: ${shib.home}]"
258 addproperty="shib.home.input" defaultvalue="${shib.home}" />
259 <var name="shib.home" value="${shib.home.input}" />
261 <input message="Enter tomcat home directory [default: ${tomcat.home}]"
262 addproperty="tomcat.home.input" defaultvalue="${tomcat.home}" />
263 <var name="tomcat.home" value="${tomcat.home.input}" />
265 <copy file="${configroot}/idp.xml.dist" tofile="${configroot}/idp.xml" overwrite="true" />
266 <replace file="${configroot}/idp.xml" token="$SHIB_HOME$" value="${shib.home}" />
267 <war warfile="${dist}/${distname}.war" webxml="${configroot}/idp.xml" basedir="${approot}" update="no" />
268 <delete file="${configroot}/idp.xml"/>
269 <copy file="${dist}/${distname}.war" tofile="${tomcat.home}/webapps/${shib.webapp.name}.war" />
272 <available file="${shib.home}/etc" />
275 <xinput type="confirm">WARNING!! The directory `${shib.home}/etc` already exists. Do you want to overwrite the existing configuration?</xinput>
277 <delete dir="${shib.home}/etc" />
278 <antcall target="install.idp.filesystem.config" />
283 <antcall target="install.idp.filesystem.config" />
287 <copy todir="${shib.home}/lib">
288 <fileset dir="lib" includesfile="conf/idp-lib.include" />
291 <copy todir="${shib.home}/bin">
295 <mkdir dir="${shib.home}/logs" />
297 <antcall target="savePropertyFile" />
300 <target name="install.idp.filesystem.config" depends="init, install.init">
301 <mkdir dir="${shib.home}/etc" />
302 <copy todir="${shib.home}/etc" overwrite="true">
303 <fileset dir="${src}/conf" includesfile="conf/idp-conf.include"/>
305 <copy file="${shib.home}/etc/idp.xml.dist" tofile="${shib.home}/etc/idp.xml" overwrite="true" />
306 <delete file="${shib.home}/etc/idp.xml.dist"/>
307 <replace file="${shib.home}/etc/idp.xml" token="$SHIB_HOME$" value="${shib.home}" />
310 <target name="install.idp.manager" depends="init, install.init">
311 <antcall target="setupTomcatTasks" />
313 <input message="Enter local tomcat directory [default: ${tomcat.home}]" addproperty="tomcat.home.input" defaultValue="${tomcat.home}" />
314 <var name="tomcat.home" value="${tomcat.home.input}" />
316 <input message="Enter tomcat url [default: ${tomcat.url}]" addproperty="tomcat.url.input" defaultValue="${tomcat.url}" />
317 <var name="tomcat.url" value="${tomcat.url.input}" />
319 <input message="Enter tomcat username [default: ${tomcat.username}]" addproperty="tomcat.username.input" defaultValue="${tomcat.username}" />
320 <var name="tomcat.username" value="${tomcat.username.input}" />
322 <input message="Enter tomcat password [default: ${tomcat.password}]" addproperty="tomcat.password.input" defaultValue="${tomcat.password}" />
323 <var name="tomcat.password" value="${tomcat.password.input}" />
325 <antcall target="tomcat.deploy" />
326 <antcall target="savePropertyFile" />
329 <target name="savePropertyFile">
330 <propertyfile file="build.properties">
331 <entry key="shib.home" value="${shib.home}" />
332 <entry key="shib.webapp.name" value="${shib.webapp.name}" />
333 <entry key="idp.install-type" value="${idp.install-type}" />
334 <entry key="tomcat.home" value="${tomcat.home}" />
335 <entry key="tomcat.url" value="${tomcat.url}" />
336 <entry key="tomcat.username" value="${tomcat.username}" />
337 <entry key="tomcat.password" value="${tomcat.password}" />
342 <!-- Create an IdP war and copy it to the pre-configured tomcat directory -->
343 <target name="copy-IdP" depends="compile" description="Copy shibboleth.war to {tomcat.home}/webapps (Tomcat must be stopped first)">
344 <!-- This task assumes that a pre-existing properties file has the correct path information -->
345 <copy file="${configroot}/idp.xml.dist" tofile="${configroot}/idp.xml" overwrite="true" />
346 <replace file="${configroot}/idp.xml" token="$SHIB_HOME$" value="${shib.home}" />
347 <war warfile="${dist}/${distname}.war" webxml="${configroot}/idp.xml" basedir="${approot}" update="no" />
348 <copy file="${dist}/${distname}.war" tofile="${tomcat.home}/webapps/${shib.webapp.name}.war" />
349 <delete dir="${tomcat.home}/webapps/${distname}" quiet="yes" />
353 <!-- Create WAYF and move it to ${dist} -->
354 <target name="package-wayf" depends="compile, clean-build">
355 <war warfile="${dist}/${distnameWayf}.war" webxml="${configroot}/wayf.xml" basedir="${approot}" update="no" />