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="build-exts" basedir=".">
10 <!-- Builds the extensions; loops through all the extension directories and builds them -->
11 <target name="build-exts" description="Compiles IdP and/or SP 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">
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-etc" />
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.
63 <property file="${ext.root}/build.properties" />
65 <!-- Load default properties -->
66 <echo message="Loading build property defaults ${exts.dir}/default-build.properties" />
67 <property file="${exts.dir}/extension-build.properties" />
69 <!-- Create needed directories -->
70 <mkdir dir="${ext.dist}" />
71 <mkdir dir="${ext.classes}" />
74 <!-- Compiles the extension -->
75 <target name="ext-compile" description="Compiles an extension">
76 <!-- Compile any source that might be out there -->
78 <available file="${ext.src}" />
80 <echo message="Compiling extension source" />
81 <javac srcdir="${ext.src}" destdir="${ext.classes}" includes="**/*.java" debug="on" source="1.4">
82 <!-- Shibboleth Classpath -->
83 <classpath refid="build.path" />
85 <!-- Extension libraries -->
87 <fileset dir="${ext.lib}">
88 <include name="**/*.jar" />
96 <!-- Copies files from etc directory to dist directory to be bundled with extension jar -->
97 <target name="ext-copy-etc" depends="ext-build-init" description="Copys non-source files to place where they will be added to jar">
98 <!-- Copy any extra stuff that needs to be on the classpath -->
100 <available file="${ext.etc}" />
102 <echo message="Detected files in the extensions 'etc' directory, ensuring they are bundled with the extension's jar." />
103 <copy todir="${ext.classes}">
104 <fileset dir="${ext.etc}">
105 <include name="**" />
112 <!-- Move third party libraries to be picked up by the war -->
113 <target name="ext-copy-libs" depends="ext-compile" description="Moves third party libraries to be picked up by the war">
115 <available file="${ext.lib}" />
117 <copy todir="${exts.dir}/lib">
118 <fileset dir="${ext.lib}" includes="*.jar" />
119 <fileset dir="${ext.dist}" includes="*.jar" />
125 <!-- Move web resources to be picked up by the war -->
126 <target name="ext-copy-webpages" depends="ext-compile" description="Moves web resources to be picked up by the war">
128 <available file="${ext.webpages}" />
130 <copy todir="${exts.dir}/web">
131 <fileset dir="${ext.webpages}"/>
138 <!-- Run any unit tests for the extension -->
139 <target name="ext-test" depends="ext-compile" description="Runs extension unit test">
141 <equals arg1="${test.ext}" arg2="true" />
144 <available file="${ext.test.src}" />
146 <echo message="Running tests cases for extension ${ext.name}" />
147 <junit printsummary="no" fork="yes" haltonerror="true" haltonfailure="true" jvm="${ext.root}">
148 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
149 <formatter type="plain" />
151 <fileset dir="${ext.test.src}" />
161 <!-- Generates the Javadocs for the extension -->
162 <target name="ext-gen-docs" description="Generates Javadocs for extension">
164 <equals arg1="${gen.ext.docs}" arg2="true" />
167 <available file="${ext.src}" />
169 <echo message="Generating javadocs for extension ${ext.name}" />
170 <javadoc sourcepath="${ext.src}" destdir="${ext.docs}" />
177 <!-- Jars up the extension -->
178 <target name="ext-package" depends="ext-compile" description="Packages up the extension">
179 <jar jarfile="${ext.dist}/${ext.name}.jar" basedir="${ext.classes}" excludes="${ext.name}.jar" />
182 <!-- Cleans up build generated resources -->
183 <target name="clean-ext" description="Cleans up any build created resources">
184 <!-- Clean up all the modules -->
185 <for keepgoing="true" param="module-path">
186 <dirset dir="${exts.dir}">
188 <exclude name="lib" />
189 <exclude name="web" />
192 <delete dir="${ext.dist}" />
196 <!-- Clean out all the staged libraries from the modules -->
197 <delete dir="${exts.dir}/lib" includeemptydirs="true">
198 <fileset dir="${exts.dir}/lib" includes="**/*" />
201 <!-- Clean out all the staged web pages from the modules -->
202 <delete dir="${exts.dir}/web" includeemptydirs="true">
203 <fileset dir="${exts.dir}/web" includes="**/*" />