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=".">
12 <!-- Loops through all the extension directories and executes a particular operation on them -->
13 <target name="ext-invoke" description="Invoke operation extensions">
14 <for keepgoing="true" param="module-path">
15 <dirset dir="${exts.dir}">
17 <exclude name="lib" />
18 <exclude name="web" />
21 <antcall target="${ext.build.function}">
22 <param name="ext.root" value="@{module-path}" />
28 <!-- Builds a single extension -->
29 <target name="ext-build" depends="ext-build-init" description="Builds the extension">
30 <echo message="--- Starting to build module ${ext.name} in ${ext.root}" />
32 <!-- Compile the source -->
33 <antcall target="ext-compile" />
35 <!-- Generate Javadocs -->
36 <antcall target="ext-gen-docs" />
38 <!-- Copy over non-source files -->
39 <antcall target="ext-copy-src-conf" />
41 <!-- Run unit tests if we're supposed to -->
42 <antcall target="ext-test" />
44 <!-- Put the libraries where the IdP and SP packaging can pick them up -->
45 <antcall target="ext-copy-libs" />
47 <!-- Put the webpages where the IdP and SP packaging can pick them up -->
48 <antcall target="ext-copy-webpages" />
50 <echo message="--- Extension ${ext.name} built" />
53 <target name="ext-load-properties" description="Loads property files needed by build process">
54 <!-- Load extension specific properties. -->
57 <available file="${ext.root}/build.properties" />
60 <fail message="No build.properties file found for extension in ${ext.root}; this file is required." />
63 <property file="${ext.root}/build.properties" />
65 <!-- Load default properties -->
66 <property file="${exts.dir}/extension-build.properties" />
68 <fail unless="ext.name" message="The extension ${ext.root} does not contain the required (ext.name) property in its build.properties file." />
71 <!-- Initialize everything we need. -->
72 <!-- The properties loaded here are scoped to this particular extension build -->
73 <target name="ext-build-init" depends="ext-load-properties" description="Sets up everything to prepare for the build">
75 <!-- Create needed directories -->
76 <mkdir dir="${ext.dist}" />
77 <mkdir dir="${ext.build}" />
78 <mkdir dir="${ext.classes}" />
79 <mkdir dir="${ext.docs}" />
82 <!-- Compiles the extension -->
83 <target name="ext-compile" description="Compiles an extension">
84 <!-- Compile any source that might be out there -->
86 <available file="${ext.src}" />
88 <echo message="Compiling extension source" />
89 <javac srcdir="${ext.src}" destdir="${ext.classes}" includes="**/*.java" debug="on" source="1.4" deprecation="true">
90 <!-- Shibboleth Libraries -->
91 <classpath refid="build.path" />
93 <!-- Shibboleth Classes -->
95 <pathelement location="${build}" />
98 <!-- Extension libraries -->
100 <fileset dir="${ext.lib}">
101 <include name="**/*.jar" />
109 <!-- Copies files from etc directory to dist directory to be bundled with extension jar -->
110 <target name="ext-copy-src-conf" description="Copys non-source files to place where they will be added to jar">
111 <!-- Copy any extra stuff that needs to be on the classpath -->
113 <available file="${ext.src.conf}" />
115 <echo message="Detected files in the extensions 'src-conf' directory, ensuring they are bundled with the extension's jar." />
116 <copy todir="${ext.classes}">
117 <fileset dir="${ext.src.conf}">
118 <include name="**" />
125 <!-- Move third party libraries to be picked up by the war -->
126 <target name="ext-copy-libs" description="Moves third party libraries to be picked up by the war">
128 <available file="${ext.lib}" />
130 <copy todir="${exts.dir}/lib">
131 <fileset dir="${ext.lib}" includes="*.jar" />
137 <!-- Move web resources to be picked up by the war -->
138 <target name="ext-copy-webpages" description="Moves web resources to be picked up by the war">
140 <available file="${ext.webpages}" />
142 <copy todir="${exts.dir}/web">
143 <fileset dir="${ext.webpages}" />
150 <!-- Run any unit tests for the extension -->
151 <target name="ext-test" description="Runs extension unit test">
153 <equals arg1="${test.ext}" arg2="true" />
156 <available file="${ext.test.src}" />
158 <echo message="Running tests cases for extension ${ext.name}" />
159 <junit printsummary="no" fork="yes" haltonerror="true" haltonfailure="true" jvm="${ext.root}">
160 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
161 <formatter type="plain" />
163 <fileset dir="${ext.test.src}" />
173 <!-- Generates the Javadocs for the extension -->
174 <target name="ext-gen-docs" description="Generates Javadocs for extension">
176 <equals arg1="${gen.ext.docs}" arg2="true" />
179 <available file="${ext.src}" />
181 <echo message="Generating javadocs for extension ${ext.name}" />
182 <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">
183 <classpath refid="build.path" />
184 <link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
192 <!-- Jars up the extension -->
195 exts.dir - the root directory of the extensions (contains all the individual extension directories)
196 ext.filesystem.home - the path on the filesystem that the extension will be installed
197 expected subdirectories are 'bin, 'etc', and 'lib'
198 ext.home.token - the token, in config files, to replace with the path to the IdP/SP home
200 <target name="ext-package" depends="ext-load-properties" description="Packages up the extension">
202 <available file="${ext.classes}" />
204 <replace dir="${ext.classes}" token="${ext.home.token}" value="${ext.filesystem.home}" excludes="*.class" />
205 <replace dir="${ext.classes}" token="$EXTENSION_NAME$" value="${ext.name}" excludes="*.class" />
206 <jar jarfile="${ext.dist}/${ext.name}.jar" basedir="${ext.classes}" update="false"/>
207 <copy file="${ext.dist}/${ext.name}.jar" todir="${exts.dir}/lib" />
208 <delete dir="${ext.classes}"/>
213 <!-- Install extension files (configuration, scripts, etc) on to the filesystem -->
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 that represents the extensions installation point within
219 the various configuration files (those in the extensions 'etc' and 'src-conf' directories)
221 <target name="ext-install-filesystem" depends="ext-build-init" description="Installs extension files on to the filesystem">
222 <echo message="Installing extension ${ext.name} to ${ext.filesystem.home}" />
224 <!-- Copy anything in the etc directory to the extension's installation point etc directory -->
226 <available file="${ext.etc}" />
229 <available file="${ext.filesystem.home}/etc/${ext.name}" />
231 <echo>--------------------------------------------------------------------------------------</echo>
233 <echo>--- NOTE: Existing Shibboleth extension module configuration at ${line.separator}--- ${ext.filesystem.home}/etc/${ext.name} will not be overwritten.</echo>
235 <echo>--------------------------------------------------------------------------------------</echo>
238 <mkdir dir="${ext.filesystem.home}/etc/${ext.name}" />
239 <copy todir="${ext.filesystem.home}/etc/${ext.name}">
240 <fileset dir="${ext.etc}">
241 <include name="**" />
244 <replace dir="${ext.filesystem.home}/etc/${ext.name}" token="${ext.home.token}" value="${ext.filesystem.home}" />
245 <replace dir="${ext.filesystem.home}/etc/${ext.name}" token="$EXTENSION_NAME$" value="${ext.name}" />
251 <!-- Copy anything in the bin directory to the extension's installation point bin directory -->
253 <available file="${ext.bin}" />
255 <copy todir="${ext.filesystem.home}/bin">
256 <fileset dir="${ext.bin}">
260 <chmod dir="${ext.filesystem.home}/bin" perm="ug+rx" includes="**/*" />
264 <!-- Copy anything in the lib directory to the extension's installation point lib directory -->
266 <available file="${ext.lib}" />
268 <copy todir="${ext.filesystem.home}/lib">
269 <fileset dir="${ext.lib}">
276 <!-- Copy the extension jar to the extension's installation point lib directory -->
278 <available file="${ext.dist}/${ext.name}.jar" />
280 <copy file="${ext.dist}/${ext.name}.jar" todir="${ext.filesystem.home}/lib" />
285 <!-- Cleans up classes files -->
286 <target name="ext-clean-build" depends="ext-load-properties" description="Cleans up any build created resources">
287 <delete dir="${ext.build}" failonerror="false" />
290 <!-- Cleans up java docs -->
291 <target name="ext-clean-javadocs" depends="ext-load-properties" description="Deletes generated javadocs">
292 <delete dir="${ext.docs}" failonerror="false" />
295 <!-- Cleans up distribution files -->
296 <target name="ext-clean-dist" depends="ext-load-properties" description="Deletes distribution generated files">
297 <delete dir="${ext.dist}" failonerror="false" />