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 <!-- Classpath for compiling an extension -->
13 <path id="ext-compile-path">
14 <!-- Shibboleth Libraries -->
15 <path refid="build.path" />
17 <!-- Extension's libraries -->
18 <fileset dir="${ext.lib}">
19 <include name="**/*.jar" />
22 <!-- Extension classes -->
23 <pathelement location="${ext.classes}" />
26 <!-- Classpath for testing an extension -->
27 <path id="ext-test-path">
28 <!-- Extension Compilation Path -->
29 <path refid="ext-compile-path" />
31 <!-- Extension test classes -->
32 <pathelement location="${ext.test.classes}" />
35 <!-- Loops through all the extension directories and executes a particular operation on them -->
36 <target name="ext-invoke" description="Invoke operation extensions">
37 <for keepgoing="true" param="module-path">
38 <dirset dir="${exts.dir}">
40 <exclude name="lib" />
41 <exclude name="web" />
44 <antcall target="${ext.build.function}">
45 <param name="ext.root" value="@{module-path}" />
51 <!-- Builds a single extension -->
52 <target name="ext-build" depends="ext-build-init" description="Builds the extension">
53 <echo message="--- Starting to build module ${ext.name} in ${ext.root}" />
55 <!-- Compile the source -->
56 <antcall target="ext-compile" />
58 <!-- Generate Javadocs -->
59 <antcall target="ext-gen-docs" />
61 <!-- Copy over non-source files -->
62 <antcall target="ext-copy-src-conf" />
64 <!-- Run unit tests if we're supposed to -->
65 <antcall target="ext-test" />
67 <!-- Put the libraries where the IdP and SP packaging can pick them up -->
68 <antcall target="ext-copy-libs" />
70 <!-- Put the webpages where the IdP and SP packaging can pick them up -->
71 <antcall target="ext-copy-webpages" />
73 <echo message="--- Extension ${ext.name} built" />
76 <target name="ext-load-properties" description="Loads property files needed by build process">
77 <!-- Load extension specific properties. -->
80 <available file="${ext.root}/build.properties" />
83 <fail message="No build.properties file found for extension in ${ext.root}; this file is required." />
86 <property file="${ext.root}/build.properties" />
88 <!-- Load default properties -->
89 <property file="${exts.dir}/extension-build.properties" />
91 <fail unless="ext.name" message="The extension ${ext.root} does not contain the required (ext.name) property in its build.properties file." />
94 <!-- Initialize everything we need. -->
95 <!-- The properties loaded here are scoped to this particular extension build -->
96 <target name="ext-build-init" depends="ext-load-properties" description="Sets up everything to prepare for the build">
98 <!-- Create needed directories -->
99 <mkdir dir="${ext.dist}" />
100 <mkdir dir="${ext.build}" />
101 <mkdir dir="${ext.classes}" />
102 <mkdir dir="${ext.test.classes}" />
103 <mkdir dir="${ext.docs}" />
106 <!-- Compiles the extension -->
107 <target name="ext-compile" description="Compiles an extension">
108 <!-- Compile any source that might be out there -->
110 <available file="${ext.src}" />
112 <echo message="Compiling extension source" />
113 <javac srcdir="${ext.src}"
114 destdir="${ext.classes}"
115 classpathref="ext-compile-path"
124 <!-- Copies files from etc directory to dist directory to be bundled with extension jar -->
125 <target name="ext-copy-src-conf" description="Copys non-source files to place where they will be added to jar">
126 <!-- Copy any extra stuff that needs to be on the classpath -->
128 <available file="${ext.src.conf}" />
130 <echo message="Detected files in the extensions 'src-conf' directory, ensuring they are bundled with the extension's jar." />
131 <copy todir="${ext.classes}">
132 <fileset dir="${ext.src.conf}">
133 <include name="**" />
140 <!-- Move third party libraries to be picked up by the war -->
141 <target name="ext-copy-libs" description="Moves third party libraries to be picked up by the war">
143 <available file="${ext.lib}" />
145 <copy todir="${exts.dir}/lib">
146 <fileset dir="${ext.lib}" includes="*.jar" />
152 <!-- Move web resources to be picked up by the war -->
153 <target name="ext-copy-webpages" description="Moves web resources to be picked up by the war">
155 <available file="${ext.webpages}" />
157 <copy todir="${exts.dir}/web">
158 <fileset dir="${ext.webpages}" />
165 <!-- Run any unit tests for the extension -->
166 <target name="ext-test" description="Runs extension unit test">
168 <equals arg1="${test.ext}" arg2="true" />
171 <available file="${ext.test.src}" />
173 <echo message="Compiling extension test source" />
174 <javac srcdir="${ext.test.src}"
175 destdir="${ext.test.classes}"
176 classpathref="ext-compile-path"
182 <!-- Copy any conf files over so that they end up on the classpathh -->
183 <copy todir="${ext.test.classes}">
184 <fileset dir="${ext.test.src}">
185 <include name="**" />
186 <exclude name="**/*.java"/>
190 <echo message="Running tests cases for extension ${ext.name}" />
191 <junit printsummary="no" fork="yes" haltonerror="true" haltonfailure="true" dir="${ext.root}">
192 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
193 <classpath refid="ext-test-path"/>
194 <formatter type="plain" />
195 <batchtest todir="${ext.root}">
196 <fileset dir="${ext.test.classes}">
197 <include name="**/*Test.class"/>
207 <!-- Generates the Javadocs for the extension -->
208 <target name="ext-gen-docs" description="Generates Javadocs for extension">
210 <equals arg1="${gen.ext.docs}" arg2="true" />
213 <available file="${ext.src}" />
215 <echo message="Generating javadocs for extension ${ext.name}" />
216 <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">
217 <classpath refid="build.path" />
218 <link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
226 <!-- Jars up the extension -->
229 exts.dir - the root directory of the extensions (contains all the individual extension directories)
230 ext.filesystem.home - the path on the filesystem that the extension will be installed
231 expected subdirectories are 'bin, 'etc', and 'lib'
232 ext.home.token - the token, in config files, to replace with the path to the IdP/SP home
234 <target name="ext-package" depends="ext-load-properties" description="Packages up the extension">
236 <available file="${ext.classes}" />
238 <replace dir="${ext.classes}" token="${ext.home.token}" value="${ext.filesystem.home}" excludes="*.class" />
239 <replace dir="${ext.classes}" token="$EXTENSION_NAME$" value="${ext.name}" excludes="*.class" />
240 <jar jarfile="${ext.dist}/${ext.name}.jar" basedir="${ext.classes}" update="false" />
241 <copy file="${ext.dist}/${ext.name}.jar" todir="${exts.dir}/lib" />
242 <delete dir="${ext.classes}" />
247 <!-- Install extension files (configuration, scripts, etc) on to the filesystem -->
250 ext.filesystem.home - the path on the filesystem that the extension will be installed
251 expected subdirectories are 'bin, 'etc', and 'lib'
252 ext.home.token - the token that represents the extensions installation point within
253 the various configuration files (those in the extensions 'etc' and 'src-conf' directories)
255 <target name="ext-install-filesystem" depends="ext-build-init" description="Installs extension files on to the filesystem">
256 <echo message="Installing extension ${ext.name} to ${ext.filesystem.home}" />
258 <!-- Copy anything in the etc directory to the extension's installation point etc directory -->
260 <available file="${ext.etc}" />
263 <available file="${ext.filesystem.home}/etc/${ext.name}" />
265 <echo>--------------------------------------------------------------------------------------</echo>
267 <echo>--- NOTE: Existing Shibboleth extension module configuration at ${line.separator}--- ${ext.filesystem.home}/etc/${ext.name} will not be overwritten.</echo>
269 <echo>--------------------------------------------------------------------------------------</echo>
272 <mkdir dir="${ext.filesystem.home}/etc/${ext.name}" />
273 <copy todir="${ext.filesystem.home}/etc/${ext.name}">
274 <fileset dir="${ext.etc}">
275 <include name="**" />
278 <replace dir="${ext.filesystem.home}/etc/${ext.name}" token="${ext.home.token}" value="${ext.filesystem.home}" />
279 <replace dir="${ext.filesystem.home}/etc/${ext.name}" token="$EXTENSION_NAME$" value="${ext.name}" />
285 <!-- Copy anything in the bin directory to the extension's installation point bin directory -->
287 <available file="${ext.bin}" />
289 <copy todir="${ext.filesystem.home}/bin">
290 <fileset dir="${ext.bin}">
291 <include name="**" />
294 <replace dir="${ext.filesystem.home}/bin" token="${ext.home.token}" value="${ext.filesystem.home}" />
295 <replace dir="${ext.filesystem.home}/bin" token="$EXTENSION_NAME$" value="${ext.name}" />
296 <chmod dir="${ext.filesystem.home}/bin" perm="ug+rx" includes="**/*" />
300 <!-- Copy anything in the lib directory to the extension's installation point lib directory -->
302 <available file="${ext.lib}" />
304 <copy todir="${ext.filesystem.home}/lib">
305 <fileset dir="${ext.lib}">
312 <!-- Copy the extension jar to the extension's installation point lib directory -->
314 <available file="${ext.dist}/${ext.name}.jar" />
316 <copy file="${ext.dist}/${ext.name}.jar" todir="${ext.filesystem.home}/lib" />
321 <!-- Cleans up classes files -->
322 <target name="ext-clean-build" depends="ext-load-properties" description="Cleans up any build created resources">
323 <delete dir="${ext.build}" failonerror="false" />
326 <!-- Cleans up java docs -->
327 <target name="ext-clean-javadocs" depends="ext-load-properties" description="Deletes generated javadocs">
328 <delete dir="${ext.docs}" failonerror="false" />
331 <!-- Cleans up distribution files -->
332 <target name="ext-clean-dist" depends="ext-load-properties" description="Deletes distribution generated files">
333 <delete dir="${ext.dist}" failonerror="false" />