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 -->
13 exts.dir - the root directory of the extensions (contains all the individual extension directories)
14 ext.build.function - the particular extension build function to invoke, acceptable values
15 ext-invoke, ext-clean, ext-install-filesystem
16 (some functions may require additional paramters, see documentation for each function)
18 <target name="ext-invoke" description="Invoke operation extensions">
19 <for keepgoing="true" param="module-path">
20 <dirset dir="${exts.dir}">
22 <exclude name="lib" />
23 <exclude name="web" />
26 <antcall target="${ext.build.function}">
27 <param name="ext.root" value="@{module-path}" />
33 <!-- Builds a single extension, called multiple times by build-exts -->
34 <target name="ext-build" depends="ext-build-init" description="Builds the extension">
35 <echo message="--- Starting to build module ${ext.name} in ${ext.root}" />
37 <!-- Compile the source -->
38 <antcall target="ext-compile" />
40 <!-- Copy over non-source files -->
41 <antcall target="ext-copy-src-conf" />
43 <!-- Generate the java docs if we're supposed to -->
44 <antcall target="ext-gen-docs" />
46 <!-- Run unit tests if we're supposed to -->
47 <antcall target="ext-test" />
49 <!-- Package everything up -->
50 <antcall target="ext-package" />
52 <!-- Put the libraries where the IdP and SP packaging can pick them up -->
53 <antcall target="ext-copy-libs" />
55 <!-- Put the webpages where the IdP and SP packaging can pick them up -->
56 <antcall target="ext-copy-webpages" />
58 <echo message="--- Extension ${ext.name} built" />
61 <!-- Initialize everything we need. -->
62 <!-- The properties loaded here are scoped to this particular extension build -->
63 <target name="ext-build-init" description="Sets up everything to prepare for the build">
64 <echo message="Loading build property files" />
66 Load extension specific properties if available. We can not set the extension's build.properties
67 file name in the extension-build.properties file because if we read that file first the extension
68 build properties won't be able to override properties in it as properties are immutable once set.
72 <available file="${ext.root}/build.properties" />
75 <fail message="No build.properties file found for extension in ${ext.root}; this file is required." />
78 <property file="${ext.root}/build.properties" />
80 <!-- Load default properties -->
81 <echo message="Loading build property defaults ${exts.dir}/default-build.properties" />
82 <property file="${exts.dir}/extension-build.properties" />
84 <fail unless="ext.name" message="The extension ${ext.root} does not contain the required (ext.name) property in its build.properties file." />
86 <!-- Create needed directories -->
87 <mkdir dir="${ext.dist}" />
88 <mkdir dir="${ext.classes}" />
91 <!-- Compiles the extension -->
92 <target name="ext-compile" description="Compiles an extension">
93 <!-- Compile any source that might be out there -->
95 <available file="${ext.src}" />
97 <echo message="Compiling extension source" />
98 <javac srcdir="${ext.src}" destdir="${ext.classes}" includes="**/*.java" debug="on" source="1.4">
99 <!-- Shibboleth Libraries -->
100 <classpath refid="build.path" />
102 <!-- Shibboleth Classes -->
104 <pathelement location="${build}" />
107 <!-- Extension libraries -->
109 <fileset dir="${ext.lib}">
110 <include name="**/*.jar" />
118 <!-- Copies files from etc directory to dist directory to be bundled with extension jar -->
119 <target name="ext-copy-src-conf" depends="ext-build-init" description="Copys non-source files to place where they will be added to jar">
120 <!-- Copy any extra stuff that needs to be on the classpath -->
122 <available file="${ext.src.conf}" />
124 <echo message="Detected files in the extensions 'etc' directory, ensuring they are bundled with the extension's jar." />
125 <copy todir="${ext.classes}">
126 <fileset dir="${ext.src.conf}">
127 <include name="**" />
134 <!-- Move third party libraries to be picked up by the war -->
135 <target name="ext-copy-libs" depends="ext-compile" description="Moves third party libraries to be picked up by the war">
137 <available file="${ext.lib}" />
139 <copy todir="${exts.dir}/lib">
140 <fileset dir="${ext.lib}" includes="*.jar" />
141 <fileset dir="${ext.dist}" includes="*.jar" />
147 <!-- Move web resources to be picked up by the war -->
148 <target name="ext-copy-webpages" depends="ext-compile" description="Moves web resources to be picked up by the war">
150 <available file="${ext.webpages}" />
152 <copy todir="${exts.dir}/web">
153 <fileset dir="${ext.webpages}" />
160 <!-- Run any unit tests for the extension -->
161 <target name="ext-test" depends="ext-compile" description="Runs extension unit test">
163 <equals arg1="${test.ext}" arg2="true" />
166 <available file="${ext.test.src}" />
168 <echo message="Running tests cases for extension ${ext.name}" />
169 <junit printsummary="no" fork="yes" haltonerror="true" haltonfailure="true" jvm="${ext.root}">
170 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
171 <formatter type="plain" />
173 <fileset dir="${ext.test.src}" />
183 <!-- Generates the Javadocs for the extension -->
184 <target name="ext-gen-docs" description="Generates Javadocs for extension">
186 <equals arg1="${gen.ext.docs}" arg2="true" />
189 <available file="${ext.src}" />
191 <echo message="Generating javadocs for extension ${ext.name}" />
192 <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">
193 <classpath refid="build.path" />
201 <!-- Jars up the extension -->
202 <target name="ext-package" depends="ext-compile" description="Packages up the extension">
203 <jar jarfile="${ext.dist}/${ext.name}.jar" basedir="${ext.classes}" excludes="${ext.name}.jar" />
206 <!-- Install extension files (configuration, scripts, etc) on to the filesystem -->
209 ext.filesystem.home - the path on the filesystem that the extension will be installed
210 expected subdirectories are 'bin, 'etc', and 'lib'
211 ext.home.token - the token that represents the extensions installation point within
212 the various configuration files (those in the extensions 'etc' and 'src-conf' directories)
214 <target name="ext-install-filesystem" depends="ext-build-init" description="Installs extension files on to the filesystem">
215 <echo message="Installing extension ${ext.name} to ${ext.filesystem.home}"/>
217 <!-- Copy anything in the etc directory to the extension's installation point etc directory -->
220 <available file="${ext.etc}" />
222 <equals arg1="${ext.install.etc}" arg2="true" />
224 <available file="${ext.filesystem.home}/etc"/>
229 <copy todir="${ext.filesystem.home}/etc">
230 <fileset dir="${ext.etc}">
234 <replace dir="${ext.filesystem.home}/etc"
235 token="${ext.home.token}"
236 value="${ext.filesystem.home}"/>
240 <!-- Copy anything in the bin directory to the extension's installation point bin directory -->
242 <available file="${ext.bin}" />
244 <copy todir="${ext.filesystem.home}/bin">
245 <fileset dir="${ext.bin}">
249 <chmod dir="${ext.filesystem.home}/bin" perm="ug+rx" includes="**/*"/>
253 <!-- Copy anything in the lib directory to the extension's installation point lib directory -->
255 <available file="${ext.lib}" />
257 <copy todir="${ext.filesystem.home}/lib">
258 <fileset dir="${ext.lib}">
265 <!-- Copy the extension jar to the extension's installation point lib directory -->
267 <available file="${ext.dist}/${ext.name}.jar"/>
269 <copy file="${ext.dist}/${ext.name}.jar" todir="${ext.filesystem.home}/lib"/>
274 <!-- Cleans up build generated resources -->
275 <target name="ext-clean" description="Cleans up any build created resources">
276 <delete dir="${ext.root}/dist" failonerror="false" />