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.
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 <!-- Create needed directories -->
78 <mkdir dir="${ext.dist}" />
79 <mkdir dir="${ext.classes}" />
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">
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-etc" depends="ext-build-init" 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.etc}" />
115 <echo message="Detected files in the extensions 'etc' directory, ensuring they are bundled with the extension's jar." />
116 <copy todir="${ext.classes}">
117 <fileset dir="${ext.etc}">
118 <include name="**" />
125 <!-- Move third party libraries to be picked up by the war -->
126 <target name="ext-copy-libs" depends="ext-compile" 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" />
132 <fileset dir="${ext.dist}" includes="*.jar" />
138 <!-- Move web resources to be picked up by the war -->
139 <target name="ext-copy-webpages" depends="ext-compile" description="Moves web resources to be picked up by the war">
141 <available file="${ext.webpages}" />
143 <copy todir="${exts.dir}/web">
144 <fileset dir="${ext.webpages}"/>
151 <!-- Run any unit tests for the extension -->
152 <target name="ext-test" depends="ext-compile" description="Runs extension unit test">
154 <equals arg1="${test.ext}" arg2="true" />
157 <available file="${ext.test.src}" />
159 <echo message="Running tests cases for extension ${ext.name}" />
160 <junit printsummary="no" fork="yes" haltonerror="true" haltonfailure="true" jvm="${ext.root}">
161 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
162 <formatter type="plain" />
164 <fileset dir="${ext.test.src}" />
174 <!-- Generates the Javadocs for the extension -->
175 <target name="ext-gen-docs" description="Generates Javadocs for extension">
177 <equals arg1="${gen.ext.docs}" arg2="true" />
180 <available file="${ext.src}" />
182 <echo message="Generating javadocs for extension ${ext.name}" />
183 <javadoc sourcepath="${ext.src}"
184 destdir="${ext.docs}"
188 windowtitle="${ext.name} Shibboleth Extension Java API"
189 doctitle="${ext.name} Shibboleth Extension Java API"
191 <classpath refid="build.path" />
199 <!-- Jars up the extension -->
200 <target name="ext-package" depends="ext-compile" description="Packages up the extension">
201 <jar jarfile="${ext.dist}/${ext.name}.jar" basedir="${ext.classes}" excludes="${ext.name}.jar" />
204 <!-- Cleans up build generated resources -->
205 <target name="ext-clean" description="Cleans up any build created resources">
206 <!-- Clean up all the modules -->
207 <for keepgoing="true" param="module-path">
208 <dirset dir="${exts.dir}">
210 <exclude name="lib" />
211 <exclude name="web" />
214 <delete dir="${ext.dist}" />