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.
8 <project name="Shibboleth-Extensions" default="ext-invoke" basedir=".">
10 <!-- Loops through all the extension directories and executes a particular operation on them -->
11 <target name="ext-invoke" description="Invoke operation extensions">
12 <for keepgoing="true" param="module-path">
13 <dirset dir="${exts.dir}">
15 <exclude name="lib" />
16 <exclude name="web" />
19 <antcall target="${ext.build.function}">
20 <param name="ext.root" value="@{module-path}" />
26 <!-- Builds a single extension, called multiple times by build-exts -->
27 <target name="ext-build" depends="ext-build-init" description="Builds the extension">
28 <echo message="--- Starting to build module ${ext.name} in ${ext.root}" />
30 <!-- Compile the source -->
31 <antcall target="ext-compile" />
33 <!-- Copy over non-source files -->
34 <antcall target="ext-copy-src-conf" />
36 <!-- Generate the java docs if we're supposed to -->
37 <antcall target="ext-gen-docs" />
39 <!-- Run unit tests if we're supposed to -->
40 <antcall target="ext-test" />
42 <!-- Package everything up -->
43 <antcall target="ext-package" />
45 <!-- Put the libraries where the IdP and SP packaging can pick them up -->
46 <antcall target="ext-copy-libs" />
48 <!-- Put the webpages where the IdP and SP packaging can pick them up -->
49 <antcall target="ext-copy-webpages" />
51 <echo message="--- Extension ${ext.name} built" />
54 <!-- Initialize everything we need. -->
55 <!-- The properties loaded here are scoped to this particular extension build -->
56 <target name="ext-build-init" description="Sets up everything to prepare for the build">
57 <echo message="Loading build property files" />
59 Load extension specific properties if available. We can not set the extension's build.properties
60 file name in the extension-build.properties file because if we read that file first the extension
61 build properties won't be able to override properties in it as properties are immutable once set.
65 <available file="${ext.root}/build.properties" />
68 <fail message="No build.properties file found for extension in ${ext.root}; this file is required." />
71 <property file="${ext.root}/build.properties" />
73 <!-- Load default properties -->
74 <echo message="Loading build property defaults ${exts.dir}/default-build.properties" />
75 <property file="${exts.dir}/extension-build.properties" />
77 <fail unless="ext.name" message="The extension ${ext.root} does not contain the required (ext.name) property in its build.properties file." />
79 <!-- Create needed directories -->
80 <mkdir dir="${ext.dist}" />
81 <mkdir dir="${ext.classes}" />
84 <!-- Compiles the extension -->
85 <target name="ext-compile" description="Compiles an extension">
86 <!-- Compile any source that might be out there -->
88 <available file="${ext.src}" />
90 <echo message="Compiling extension source" />
91 <javac srcdir="${ext.src}" destdir="${ext.classes}" includes="**/*.java" debug="on" source="1.4">
92 <!-- Shibboleth Libraries -->
93 <classpath refid="build.path" />
95 <!-- Shibboleth Classes -->
97 <pathelement location="${build}" />
100 <!-- Extension libraries -->
102 <fileset dir="${ext.lib}">
103 <include name="**/*.jar" />
111 <!-- Copies files from etc directory to dist directory to be bundled with extension jar -->
112 <target name="ext-copy-src-conf" depends="ext-build-init" description="Copys non-source files to place where they will be added to jar">
113 <!-- Copy any extra stuff that needs to be on the classpath -->
115 <available file="${ext.src.conf}" />
117 <echo message="Detected files in the extensions 'etc' directory, ensuring they are bundled with the extension's jar." />
118 <copy todir="${ext.classes}">
119 <fileset dir="${ext.src.conf}">
120 <include name="**" />
127 <!-- Move third party libraries to be picked up by the war -->
128 <target name="ext-copy-libs" depends="ext-compile" description="Moves third party libraries to be picked up by the war">
130 <available file="${ext.lib}" />
132 <copy todir="${exts.dir}/lib">
133 <fileset dir="${ext.lib}" includes="*.jar" />
139 <!-- Move web resources to be picked up by the war -->
140 <target name="ext-copy-webpages" depends="ext-compile" description="Moves web resources to be picked up by the war">
142 <available file="${ext.webpages}" />
144 <copy todir="${exts.dir}/web">
145 <fileset dir="${ext.webpages}" />
152 <!-- Run any unit tests for the extension -->
153 <target name="ext-test" depends="ext-compile" description="Runs extension unit test">
155 <equals arg1="${test.ext}" arg2="true" />
158 <available file="${ext.test.src}" />
160 <echo message="Running tests cases for extension ${ext.name}" />
161 <junit printsummary="no" fork="yes" haltonerror="true" haltonfailure="true" jvm="${ext.root}">
162 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
163 <formatter type="plain" />
165 <fileset dir="${ext.test.src}" />
175 <!-- Generates the Javadocs for the extension -->
176 <target name="ext-gen-docs" description="Generates Javadocs for extension">
178 <equals arg1="${gen.ext.docs}" arg2="true" />
181 <available file="${ext.src}" />
183 <echo message="Generating javadocs for extension ${ext.name}" />
184 <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">
185 <classpath refid="build.path" />
193 <!-- Jars up the extension -->
196 exts.dir - the root directory of the extensions (contains all the individual extension directories)
197 ext.build.function - the particular extension build function to invoke, acceptable values
198 ext-invoke, ext-clean, ext-install-filesystem
199 (some functions may require additional paramters, see documentation for each function)
200 ext.filesystem.home - the path on the filesystem that the extension will be installed
201 expected subdirectories are 'bin, 'etc', and 'lib'
202 ext.home.token - the token, in config files, to replace with the path to the IdP/SP home
204 <target name="ext-package" depends="ext-build-init" description="Packages up the extension">
206 <available file="${ext.classes}"/>
208 <replace dir="${ext.classes}" token="${ext.home.token}" value="${ext.filesystem.home}" excludes="*.class"/>
209 <replace dir="${ext.classes}" token="$EXTENSION_NAME$" value="${ext.name}" excludes="*.class"/>
210 <jar jarfile="${ext.dist}/${ext.name}.jar" basedir="${ext.classes}"/>
211 <copy file="${ext.dist}/${ext.name}.jar" todir="${exts.dir}/lib"/>
216 <!-- Install extension files (configuration, scripts, etc) on to the filesystem -->
219 ext.filesystem.home - the path on the filesystem that the extension will be installed
220 expected subdirectories are 'bin, 'etc', and 'lib'
221 ext.home.token - the token that represents the extensions installation point within
222 the various configuration files (those in the extensions 'etc' and 'src-conf' directories)
224 <target name="ext-install-filesystem" depends="ext-build-init" description="Installs extension files on to the filesystem">
225 <echo message="Installing extension ${ext.name} to ${ext.filesystem.home}" />
227 <!-- Copy anything in the etc directory to the extension's installation point etc directory -->
229 <available file="${ext.etc}" />
232 <available file="${ext.filesystem.home}/etc/${ext.name}" />
234 <echo>--------------------------------------------------------------------------------------</echo>
236 <echo>--- NOTE: Existing Shibboleth extension module configuration at ${line.separator}--- ${ext.filesystem.home}/etc/${ext.name} will not be overwritten.</echo>
238 <echo>--------------------------------------------------------------------------------------</echo>
241 <mkdir dir="${ext.filesystem.home}/etc/${ext.name}" />
242 <copy todir="${ext.filesystem.home}/etc/${ext.name}">
243 <fileset dir="${ext.etc}">
247 <replace dir="${ext.filesystem.home}/etc/${ext.name}" token="${ext.home.token}" value="${ext.filesystem.home}" />
248 <replace dir="${ext.filesystem.home}/etc/${ext.name}" token="$EXTENSION_NAME$" value="${ext.name}" />
254 <!-- Copy anything in the bin directory to the extension's installation point bin directory -->
256 <available file="${ext.bin}" />
258 <copy todir="${ext.filesystem.home}/bin">
259 <fileset dir="${ext.bin}">
263 <chmod dir="${ext.filesystem.home}/bin" perm="ug+rx" includes="**/*" />
267 <!-- Copy anything in the lib directory to the extension's installation point lib directory -->
269 <available file="${ext.lib}" />
271 <copy todir="${ext.filesystem.home}/lib">
272 <fileset dir="${ext.lib}">
279 <!-- Copy the extension jar to the extension's installation point lib directory -->
281 <available file="${ext.dist}/${ext.name}.jar" />
283 <copy file="${ext.dist}/${ext.name}.jar" todir="${ext.filesystem.home}/lib" />
288 <!-- Cleans up build generated resources -->
289 <target name="ext-clean" description="Cleans up any build created resources">
290 <delete dir="${ext.root}/dist" failonerror="false" />