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="standard-ext-build">
20 <param name="ext.root" value="@{module-path}" />
26 <!-- Builds a single extension, called multiple times by build-exts -->
27 <target name="standard-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="compile-ext" />
33 <!-- Copy over non-source files -->
34 <antcall target="copy-etc" />
36 <!-- Generate the java docs if we're supposed to -->
37 <antcall target="gen-ext-docs" />
39 <!-- Run unit tests if we're supposed to -->
40 <antcall target="test-ext" />
42 <!-- Package everything up -->
43 <antcall target="package-ext" />
45 <!-- Put the libraries where the IdP and SP packaging can pick them up -->
46 <copy todir="${exts.dir}/lib">
47 <fileset dir="${ext.lib}" includes="*.jar" />
48 <fileset dir="${ext.dist}" includes="*.jar" />
51 <!-- Put the webpages where the IdP and SP packaging can pick them up -->
52 <copy todir="${exts.dir}/web">
53 <fileset dir="${ext.webpages}" includes="*" />
55 <echo message="--- Extension ${ext.name} built" />
58 <!-- Initialize everything we need. -->
59 <!-- The properties loaded here are scoped to this particular extension build -->
60 <target name="ext-build-init" description="Sets up everything to prepare for the build">
61 <echo message="Loading build property files" />
63 Load extension specific properties if available. We can not set the extension's build.properties
64 file name in the extension-build.properties file because if we read that file first the extension
65 build properties won't be able to override properties in it as properties are immutable once set.
67 <property file="${ext.root}/build.properties" />
69 <!-- Load default properties -->
70 <echo message="Loading build property defaults ${exts-dir}/default-build.properties" />
71 <property file="${exts.dir}/extension-build.properties" />
73 <!-- Create needed directories -->
74 <mkdir dir="${ext.dist}" />
75 <mkdir dir="${ext.classes}" />
78 <!-- Compiles the extension -->
79 <target name="compile-ext" depends="ext-build-init" description="Compiles an extension">
80 <!-- Compile any source that might be out there -->
82 <available file="${ext.src}" />
84 <echo message="Compiling extension source" />
85 <javac srcdir="${ext.src}" destdir="${ext.classes}" includes="**/*.java" debug="on" source="1.4">
86 <!-- Shibboleth Classpath -->
87 <classpath refid="build.path" />
89 <!-- Extension libraries -->
91 <fileset dir="${ext.lib}">
92 <include name="**/*.jar" />
100 <!-- Copies files from etc directory to dist directory to be bundled with extension jar -->
101 <target name="copy-etc" depends="ext-build-init" description="Copys non-source files to place where they will be added to jar">
102 <!-- Copy any extra stuff that needs to be on the classpath -->
104 <available file="${ext.etc}" />
106 <echo message="Detected files in the extensions 'etc' directory, ensuring they are bundled with the extension's jar." />
107 <copy todir="${ext.classes}">
108 <fileset dir="${ext.etc}">
109 <include name="**" />
116 <!-- Run any unit tests for the extension -->
117 <target name="test-ext" depends="compile-ext" description="Runs extension unit test">
119 <equals arg1="${test.ext}" arg2="true" />
122 <available file="${ext.test.src}" />
124 <echo message="Running tests cases for extension ${ext.name}" />
125 <junit printsummary="no" fork="yes" haltonerror="true" haltonfailure="true" jvm="${ext.root}">
126 <jvmarg value="-Djava.endorsed.dirs=${endorsed}" />
127 <formatter type="plain" />
129 <fileset dir="${ext.test.src}" />
139 <!-- Generates the Javadocs for the extension -->
140 <target name="gen-ext-docs" description="Generates Javadocs for extension">
142 <equals arg1="${gen.ext.docs}" arg2="true" />
145 <available file="${ext.etc}" />
147 <echo message="Generating javadocs for extension ${ext.name}" />
148 <javadoc sourcepath="${ext.src}" destdir="${ext.docs}" />
155 <!-- Jars up the extension -->
156 <target name="package-ext" depends="compile-ext" description="Packages up the extension">
157 <jar jarfile="${ext.dist}/${ext.name}.jar" basedir="${ext.dist}" excludes="${ext.name}.jar" />
160 <!-- Cleans up build generated resources -->
161 <target name="clean-ext" description="Cleans up any build created resources">
162 <!-- Clean up all the modules -->
163 <for keepgoing="true" param="module-path">
164 <dirset dir="${exts.dir}">
166 <exclude name="lib" />
167 <exclude name="web" />
170 <delete dir="${ext.dist}" />
174 <!-- Clean out all the staged libraries from the modules -->
175 <delete dir="${exts.dir}/lib" includeemptydirs="true">
176 <fileset dir="${exts.dir}/lib" includes="**/*" />
179 <!-- Clean out all the staged web pages from the modules -->
180 <delete dir="${exts.dir}/web" includeemptydirs="true">
181 <fileset dir="${exts.dir}/web" includes="**/*" />