Compile for jdk 1.4.
[java-idp.git] / build.xml
1 <!-- Main build configutaion for Shibboleth java components - Walter Hoehn 06/04/2002 -->
2
3 <project name="Shibboleth" default="dist-IdP" 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         <!-- Configure properties to find Tomcat and access the Manager application -->
26         <property name="tomcat.home" value="/usr/local/tomcat"/>
27         <property name="url" value="http://localhost:8080/manager"/>
28         <property name="username" value="manager"/>
29         <property name="password" value="password"/>
30
31         <!-- Uncomment this for Tomcat Tasks
32         <path id="tomcat.classpath">
33         <fileset dir="${tomcat.home}/server/lib" includes="catalina-ant.jar"/>
34         </path>
35
36         <taskdef name="tomcatStart" classname="org.apache.catalina.ant.StartTask" classpathref="tomcat.classpath"/>
37         <taskdef name="tomcatStop" classname="org.apache.catalina.ant.StopTask" classpathref="tomcat.classpath"/>
38         <taskdef name="tomcatDeploy" classname="org.apache.catalina.ant.DeployTask" classpathref="tomcat.classpath"/>
39         <taskdef name="tomcatUndeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="tomcat.classpath"/>
40         -->
41         
42     <!-- Construct the CLASSPATH -->
43     <path id="build.path">
44         <pathelement path="${classpath}" />
45         <pathelement location="${build}" />
46         <fileset dir="${libdir}">
47             <include name="**/*.jar" />
48         </fileset>
49         <fileset dir="${buildlibs}">
50             <include name="**/*.jar" />
51         </fileset>
52     </path>
53
54
55     <!-- Prepare directory structure for project build-->
56     <target name="init">
57     <mkdir dir="${build}" />
58     <mkdir dir="${dist}" />
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" 
70                 target="1.4" source="1.4">
71             <classpath refid="build.path" />
72         </javac>
73         <copy todir="${build}/schemas">
74             <fileset dir="${src}/schemas"/>
75         </copy>
76         <copy todir="${build}/conf">
77             <fileset dir="${src}/conf"/>
78         </copy>
79     </target>
80     
81     <target name="compile-tests" depends="compile">
82         <javac srcdir="${tests}" destdir="${build}" includes="**/*.java" debug="on">
83             <classpath refid="build.path" />
84         </javac>
85     </target>
86
87
88         <!-- Generate API docs -->
89         <target name="javadocs">
90                 <mkdir dir="${docs}" />
91                 <mkdir dir="${javadocs}" />
92                 <javadoc packagenames='edu.internet2.middleware.*'
93                         sourcepath='${src}' destdir='${javadocs}'
94                         author='true' version='true'
95                         windowtitle='Shibboleth Java API' doctitle='Shibboleth Java API'
96                         bottom='${copyright}'>
97                 <classpath refid="build.path" />
98         </javadoc>
99         </target>
100
101     <!-- Create various product distributions and move them to ${dist} -->
102
103     <target name="dist-all" depends="compile, test-all, package-all, clean-build" />
104         
105     <target name="package-all">
106         <war warfile="${dist}/${distname}.war" webxml="${configroot}/all.xml" basedir="${approot}" update="no" />
107     </target>
108
109     <target name="dist-IdP" depends="compile, test-IdP, package-IdP, clean-build" />
110     <target name="package-IdP">
111         <war warfile="${dist}/${distname}.war" webxml="${configroot}/origin.xml" basedir="${approot}" update="no" />
112     </target>
113         
114     <target name="dist-IdP-SP" depends="compile, package-IdP-SP, clean-build" 
115         description="Build application from source, create shibboleth.war file for IdP and SP"/>
116     <target name="package-IdP-SP" depends="compile"
117         description="Create shibboleth.war file from build output and IdP-SP deployment descriptor">
118         <war warfile="${dist}/${distname}.war" webxml="${configroot}/IdP-SP.xml" basedir="${approot}" update="no" />
119     </target>
120
121     <target name="dist-wayf" depends="compile, package-wayf, clean-build" />
122     <target name="package-wayf">
123         <war warfile="${dist}/${distname}-wayf.war" webxml="${configroot}/wayf.xml" basedir="${approot}" update="no" />
124     </target>
125
126     <!-- Build utilities -->
127     <target name="build-util" depends="compile">
128         <jar jarfile="${distlibs}/shib-util.jar" basedir="${build}" />
129     </target>
130
131     
132     <!-- Cleanup after the build, test, and distribution processes -->
133     <target name="clean" depends="clean-all" />
134     <target name="clean-all" depends="clean-build, clean-dist, clean-test, clean-javadocs, clean-util" />
135     <target name="clean-build">
136         <delete dir="${build}" />
137     </target>
138     <target name="clean-test">
139         <delete>
140             <fileset dir="${root}">
141                 <include name="**/TEST*.txt" />
142             </fileset>
143         </delete>
144     </target>
145     <target name="clean-dist">
146         <delete dir="${dist}" />
147     </target>
148         <target name="clean-javadocs">
149                 <delete dir="${javadocs}" />
150         </target>
151     <target name="clean-util">
152         <delete>
153             <fileset dir="${buildlibs}">
154                 <include name="shib-util.jar" />
155             </fileset>
156         </delete>
157     </target>
158
159     <!-- Run automated tests on compiled code -->
160     <target name="test-all" depends="test-IdP" />
161     <target name="test-IdP" depends="compile-tests">
162         <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes" dir="${root}">
163                         <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
164             <classpath refid="build.path" />
165             <formatter type="plain" />
166             <test name="edu.internet2.middleware.shibboleth.aa.arp.ArpTests" />
167                         <test name="edu.internet2.middleware.shibboleth.aa.attrresolv.ResolverTests" />
168         </junit>
169     </target>
170     
171     <!-- Tomcat Management -->
172     <target name="start" description="Start a deployed webapp using Tomcat manager">
173         <tomcatStop url="${url}" username="${username}" password="${password}" path="/${distname}"/>
174     </target>
175
176     <target name="stop" description="Stop a deployed webapp using Tomcat manager">
177         <tomcatStop url="${url}" username="${username}" password="${password}" path="/${distname}"/>
178     </target>
179
180     <target name="deploy" description="Upload and deploy using Tomcat manager">
181         <tomcatDeploy url="${url}" username="${username}" password="${password}" path="/${distname}"
182                 war="file:${basedir}/${dist}/${distname}.war"/>
183     </target>
184
185     <target name="undeploy" description="Undeploy using Tomcat manager">
186         <tomcatUndeploy url="${url}" username="${username}" password="${password}" path="/${distname}"/>
187     </target>
188         
189         <target name="distcopy" description="Copy shibboleth.war to {tomcat.home}/webapps (Tomcat must be stopped first)">
190                 <!-- Deploy war file by copy and delete. Tomcat must not be
191                      running when this occurs. --> 
192                 <copy file="${dist}/${distname}.war" 
193                         tofile="${tomcat.home}/webapps/${distname}.war" 
194                 />
195                 <delete dir="${tomcat.home}/webapps/${distname}" quiet="yes" />
196         </target>
197         
198     
199     <!-- Automated key generation -->
200         <target name="genSecret" depends="compile">
201         <taskdef name="genSecret" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
202                 <genSecret keyStorePath="${appconfig}/handle.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
203         </target>
204
205     <target name="genSalt" depends="compile">
206         <taskdef name="genSalt" classname="edu.internet2.middleware.shibboleth.utils.HandleRepositorySecretGenerator" classpathref="build.path"/>
207         <genSalt keyStorePath="${appconfig}/persistent.jks" keyStorePassword="shibhs" keyStoreKeyAlias="handleKey" keyStoreKeyPassword="shibhs" />
208     </target>
209         
210         <target name="exampleCertificate">
211                 <genkey alias="tomcat" storepass="exampleorg"
212                         keystore="${tomcat.home}/conf/example.jks"
213                         keyalg="RSA" validity="365"
214                         dname="cn=shibboleth.example.org, o=example.org, c=US"
215                 />
216         </target>
217 </project>