2 This file is imported in to the main Shibboleth build.xml file and
3 contains all targets used for building IdP and SP extensions. These
4 targets are not designed to be called by anything other than the main
10 <project name="Shibboleth-Extensions" default="ext-invoke" basedir=".">
13 <!-- Shibboleth Libraries -->
14 <path refid="build.path" />
16 <!-- Shibboleth Classes -->
17 <pathelement location="${build}" />
19 <!-- Extension libraries -->
20 <fileset dir="${ext.lib}">
21 <include name="**/*.jar" />
24 <!-- Extension classes -->
25 <pathelement location="${ext.classes}" />
27 <!-- Extension test classes -->
28 <pathelement location="${ext.test.classes}" />
31 <!-- Loops through all the extension directories and executes a particular operation on them -->
32 <target name="ext-invoke" description="Invoke operation extensions">
33 <for keepgoing="true" param="module-path">
34 <dirset dir="${exts.dir}">
36 <exclude name="lib" />
37 <exclude name="web" />
40 <antcall target="${ext.build.function}">
41 <param name="ext.root" value="@{module-path}" />
47 <!-- Builds a single extension -->
48 <target name="ext-build" depends="ext-build-init" description="Builds the extension">
49 <echo message="--- Starting to build module ${ext.name} in ${ext.root}" />
51 <!-- Compile the source -->
52 <antcall target="ext-compile" />
54 <!-- Generate Javadocs -->
55 <antcall target="ext-gen-docs" />
57 <!-- Copy over non-source files -->
58 <antcall target="ext-copy-src-conf" />
60 <!-- Run unit tests if we're supposed to -->
61 <antcall target="ext-test" />
63 <!-- Put the libraries where the IdP and SP packaging can pick them up -->
64 <antcall target="ext-copy-libs" />
66 <!-- Put the webpages where the IdP and SP packaging can pick them up -->
67 <antcall target="ext-copy-webpages" />
69 <echo message="--- Extension ${ext.name} built" />
72 <target name="ext-load-properties" description="Loads property files needed by build process">
73 <!-- Load extension specific properties. -->
76 <available file="${ext.root}/build.properties" />
79 <fail message="No build.properties file found for extension in ${ext.root}; this file is required." />
82 <property file="${ext.root}/build.properties" />
84 <!-- Load default properties -->
85 <property file="${exts.dir}/extension-build.properties" />
87 <fail unless="ext.name" message="The extension ${ext.root} does not contain the required (ext.name) property in its build.properties file." />
90 <!-- Initialize everything we need. -->
91 <!-- The properties loaded here are scoped to this particular extension build -->
92 <target name="ext-build-init" depends="ext-load-properties" description="Sets up everything to prepare for the build">
94 <!-- Create needed directories -->
95 <mkdir dir="${ext.dist}" />
96 <mkdir dir="${ext.build}" />
97 <mkdir dir="${ext.classes}" />
98 <mkdir dir="${ext.test.classes}" />
99 <mkdir dir="${ext.docs}" />
102 <!-- Compiles the extension -->
103 <target name="ext-compile" description="Compiles an extension">
104 <!-- Compile any source that might be out there -->
106 <available file="${ext.src}" />
108 <echo message="Compiling extension source" />
109 <javac srcdir="${ext.src}"
110 destdir="${ext.classes}"
111 classpathref="ext.path"
120 <!-- Copies files from etc directory to dist directory to be bundled with extension jar -->
121 <target name="ext-copy-src-conf" description="Copys non-source files to place where they will be added to jar">
122 <!-- Copy any extra stuff that needs to be on the classpath -->
124 <available file="${ext.src.conf}" />
126 <echo message="Detected files in the extensions 'src-conf' directory, ensuring they are bundled with the extension's jar." />
127 <copy todir="${ext.classes}">
128 <fileset dir="${ext.src.conf}">
129 <include name="**" />
136 <!-- Move third party libraries to be picked up by the war -->
137 <target name="ext-copy-libs" description="Moves third party libraries to be picked up by the war">
139 <available file="${ext.lib}" />
141 <copy todir="${exts.dir}/lib">
142 <fileset dir="${ext.lib}" includes="*.jar" />
148 <!-- Move web resources to be picked up by the war -->
149 <target name="ext-copy-webpages" description="Moves web resources to be picked up by the war">
151 <available file="${ext.webpages}" />
153 <copy todir="${exts.dir}/web">
154 <fileset dir="${ext.webpages}" />
161 <!-- Run any unit tests for the extension -->
162 <target name="ext-test" description="Runs extension unit test">
164 <equals arg1="${test.ext}" arg2="true" />
167 <available file="${ext.test.src}" />
169 <echo message="Compiling extension test source" />
170 <javac srcdir="${ext.test.src}"
171 destdir="${ext.test.classes}"
172 classpathref="ext.path"
178 <echo message="Running tests cases for extension ${ext.name}" />
179 <junit printsummary="no" fork="yes" haltonerror="true" haltonfailure="true" dir="${ext.root}">
180 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
181 <classpath refid="ext.path"/>
182 <formatter type="plain" />
183 <batchtest todir="${ext.root}">
184 <fileset dir="${ext.test.classes}" />
193 <!-- Generates the Javadocs for the extension -->
194 <target name="ext-gen-docs" description="Generates Javadocs for extension">
196 <equals arg1="${gen.ext.docs}" arg2="true" />
199 <available file="${ext.src}" />
201 <echo message="Generating javadocs for extension ${ext.name}" />
202 <javadoc sourcepath="${ext.src}" destdir="${ext.docs}" packagenames="*" author="true" version="true" windowtitle="${ext.name} Shibboleth Extension Java API" doctitle="${ext.name} Shibboleth Extension Java API" failonerror="false">
203 <classpath refid="build.path" />
204 <link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
212 <!-- Jars up the extension -->
215 exts.dir - the root directory of the extensions (contains all the individual extension directories)
216 ext.filesystem.home - the path on the filesystem that the extension will be installed
217 expected subdirectories are 'bin, 'etc', and 'lib'
218 ext.home.token - the token, in config files, to replace with the path to the IdP/SP home
220 <target name="ext-package" depends="ext-load-properties" description="Packages up the extension">
222 <available file="${ext.classes}" />
224 <replace dir="${ext.classes}" token="${ext.home.token}" value="${ext.filesystem.home}" excludes="*.class" />
225 <replace dir="${ext.classes}" token="$EXTENSION_NAME$" value="${ext.name}" excludes="*.class" />
226 <jar jarfile="${ext.dist}/${ext.name}.jar" basedir="${ext.classes}" update="false" />
227 <copy file="${ext.dist}/${ext.name}.jar" todir="${exts.dir}/lib" />
228 <delete dir="${ext.classes}" />
233 <!-- Install extension files (configuration, scripts, etc) on to the filesystem -->
236 ext.filesystem.home - the path on the filesystem that the extension will be installed
237 expected subdirectories are 'bin, 'etc', and 'lib'
238 ext.home.token - the token that represents the extensions installation point within
239 the various configuration files (those in the extensions 'etc' and 'src-conf' directories)
241 <target name="ext-install-filesystem" depends="ext-build-init" description="Installs extension files on to the filesystem">
242 <echo message="Installing extension ${ext.name} to ${ext.filesystem.home}" />
244 <!-- Copy anything in the etc directory to the extension's installation point etc directory -->
246 <available file="${ext.etc}" />
249 <available file="${ext.filesystem.home}/etc/${ext.name}" />
251 <echo>--------------------------------------------------------------------------------------</echo>
253 <echo>--- NOTE: Existing Shibboleth extension module configuration at ${line.separator}--- ${ext.filesystem.home}/etc/${ext.name} will not be overwritten.</echo>
255 <echo>--------------------------------------------------------------------------------------</echo>
258 <mkdir dir="${ext.filesystem.home}/etc/${ext.name}" />
259 <copy todir="${ext.filesystem.home}/etc/${ext.name}">
260 <fileset dir="${ext.etc}">
261 <include name="**" />
264 <replace dir="${ext.filesystem.home}/etc/${ext.name}" token="${ext.home.token}" value="${ext.filesystem.home}" />
265 <replace dir="${ext.filesystem.home}/etc/${ext.name}" token="$EXTENSION_NAME$" value="${ext.name}" />
271 <!-- Copy anything in the bin directory to the extension's installation point bin directory -->
273 <available file="${ext.bin}" />
275 <copy todir="${ext.filesystem.home}/bin">
276 <fileset dir="${ext.bin}">
280 <chmod dir="${ext.filesystem.home}/bin" perm="ug+rx" includes="**/*" />
284 <!-- Copy anything in the lib directory to the extension's installation point lib directory -->
286 <available file="${ext.lib}" />
288 <copy todir="${ext.filesystem.home}/lib">
289 <fileset dir="${ext.lib}">
296 <!-- Copy the extension jar to the extension's installation point lib directory -->
298 <available file="${ext.dist}/${ext.name}.jar" />
300 <copy file="${ext.dist}/${ext.name}.jar" todir="${ext.filesystem.home}/lib" />
305 <!-- Cleans up classes files -->
306 <target name="ext-clean-build" depends="ext-load-properties" description="Cleans up any build created resources">
307 <delete dir="${ext.build}" failonerror="false" />
310 <!-- Cleans up java docs -->
311 <target name="ext-clean-javadocs" depends="ext-load-properties" description="Deletes generated javadocs">
312 <delete dir="${ext.docs}" failonerror="false" />
315 <!-- Cleans up distribution files -->
316 <target name="ext-clean-dist" depends="ext-load-properties" description="Deletes distribution generated files">
317 <delete dir="${ext.dist}" failonerror="false" />