username/pass auth handler - initial rev.
[java-idp.git] / build.xml
1 <project name="Shibboleth Identity Provider" basedir="." default="package">
2         
3         <tstamp>
4                 <format property="build-date" pattern="ddMMyyyy'T'kkmmss" timezone="GMT"/>
5         </tstamp>\r
6
7         <!-- User based property file that overrides any property below -->
8         <property file="${user.name}-build.properties"/>
9                 
10         <!-- Project based property file -->\r
11     <property file="build.properties" />\r
12 \r
13     <!-- Load ant-contrib tasks -->\r
14     <taskdef resource="net/sf/antcontrib/antlib.xml" />
15         
16         <!-- Load Checkstyle tasks -->
17         <taskdef resource="checkstyletask.properties" />\r
18 \r
19     <!-- Classpath for building core classes-->\r
20     <path id="build-path">\r
21         <fileset dir="${build-lib.dir}" includes="**/*.jar" />\r
22         <fileset dir="${lib.dir}" includes="**/*.jar" />\r
23     </path>\r
24 \r
25     <!-- Classpath for testing classes-->\r
26     <path id="test-path">\r
27         <path refid="build-path" />\r
28         <pathelement location="${core-classes.dir}" />\r
29         <pathelement location="${core-src.dir}" />\r
30         <pathelement location="${test-classes.dir}" />
31         <pathelement location="${test-classes.dir}/data" />
32         <pathelement location="${test-classes.dir}/log4j.xml" />\r
33         <pathelement location="${test-src.dir}" />\r
34         <pathelement location="${classpathres.dir}" />\r
35     </path>\r
36 \r
37     <!-- Prepare directory structure for build -->\r
38     <target name="build-init">\r
39         <mkdir dir="${build.dir}" />\r
40     </target>\r
41 \r
42     <!-- Compile core (non-test) classes -->\r
43     <target name="compile-core" depends="build-init, clean-compile">\r
44         <mkdir dir="${core-classes.dir}" />\r
45 \r
46         <javac srcdir="${core-src.dir}" destdir="${core-classes.dir}" includes="**/*.java" debug="on" source="1.5">\r
47             <classpath refid="build-path" />\r
48         </javac>\r
49 \r
50     </target>\r
51 \r
52     <!-- Compile unit test classes -->\r
53     <target name="compile-test" depends="compile-core">\r
54         <mkdir dir="${test-classes.dir}" />\r
55 \r
56         <javac srcdir="${test-src.dir}" destdir="${test-classes.dir}" includes="**/*.java" debug="on" source="1.5">\r
57             <classpath refid="test-path" />\r
58         </javac>\r
59 \r
60     </target>\r
61 \r
62     <!-- Compile and run unit tests -->\r
63     <target name="test" depends="compile-core, compile-test" description="Runs the unit tests for the project.">\r
64         <mkdir dir="${test-results.dir}" />\r
65 \r
66         <echo message="Excuting unit tests using endorsed directory ${java.endorsed.dirs}" />\r
67         <junit printsummary="off" fork="yes" forkmode="once" haltonerror="false" haltonfailure="false" dir="${basedir}" errorproperty="testFailed">\r
68                 <jvmarg value="-Djava.endorsed.dirs=${java.endorsed.dirs}" />\r
69             <classpath refid="test-path" />\r
70             <formatter type="xml" />\r
71             <batchtest todir="${test-results.dir}">\r
72                 <fileset dir="${test-classes.dir}">\r
73                     <include name="**/*Test.class" />\r
74                 </fileset>\r
75             </batchtest>\r
76         </junit>\r
77         <junitreport todir="${test-results.dir}">\r
78           <fileset dir="${test-results.dir}">\r
79             <include name="TEST-*.xml"/>\r
80           </fileset>\r
81           <report format="frames" todir="${test-report.dir}"/>\r
82         </junitreport>
83         
84         <echo message="Test report available at ${test-report.dir}/index.html" />
85         <fail if="testFailed" message="Test failure; see ${test-report.dir}/index.html for more information."/>\r
86     </target>\r
87 \r
88     <!-- Javadoc core (non-test) classes -->\r
89     <target name="javadoc" description="Creates the JavaDoc documentatin for the project.">\r
90         <mkdir dir="${javadoc.dir}" />\r
91         <javadoc packagenames="org.opensaml.*" \r
92                      sourcepath="${core-src.dir}" \r
93                      destdir="${javadoc.dir}" \r
94                      author="false" version="true" \r
95                      windowtitle="${ant.project.name} ${version} Java API" \r
96                      doctitle="${ant.project.name} ${version} Java API" \r
97                      bottom="${copyright}"\r
98                      overview="${core-src.dir}/overview.html">\r
99             <classpath refid="build-path" />\r
100         </javadoc>\r
101     </target>\r
102 \r
103     <!-- Removes previously compiled files -->\r
104     <target name="clean-compile">\r
105         <delete dir="${build.dir}" />\r
106     </target>\r
107 \r
108     <!-- Removes all build generated content -->\r
109     <target name="clean" depends="clean-compile" description="Removes any artifact produced by the build process.">\r
110         <delete dir="${javadoc.dir}" />
111         <delete dir="${reports.dir}" />\r
112         <delete dir="${dist.dir}" />\r
113     </target>\r
114 \r
115     <!-- Create JAR file -->\r
116     <target name="package" depends="compile-core, test" description="Creates the project library jar file.">\r
117         <mkdir dir="${dist.dir}" />\r
118 \r
119         <if>\r
120             <equals arg1="${jdk.target}" arg2="1.4" />\r
121             <then>\r
122                 <java classname="com.rc.retroweaver.Weaver">\r
123                     <arg value="-source" />\r
124                     <arg value="${core-classes.dir}" />\r
125                     <classpath>\r
126                         <fileset dir="${thirdpaty-lib.dir}">\r
127                             <include name="**/*.jar" />\r
128                         </fileset>\r
129                     </classpath>\r
130                 </java>\r
131 \r
132                 <echo message="**************************************************************" />\r
133                 <echo message="    Remember, you must include the retroweaver-rt jar" />\r
134                 <echo message="    file, located in the thirdparty-lib directory, along with the" />\r
135                 <echo message="    ${jar.name} on your" />\r
136                 <echo message="    classpath in order to use this with JDK 1.4" />\r
137                 <echo message="**************************************************************" />\r
138 \r
139             </then>\r
140         </if>\r
141 \r
142         <jar destfile="${dist.dir}/${jar.name}" whenempty="fail">\r
143                 <fileset dir="${classpathres.dir}" />
144                 <fileset dir="${metainf.dir}" />
145                 <fileset dir="${webinf.dir}" />
146                 <fileset dir="${webpages.dir}" />
147                 <zipfileset dir="${core-classes.dir}" prefix="/WEB-INF/classes/" />
148                 <zipfileset dir="${lib.dir}" prefix="/WEB-INF/lib/" />\r
149         </jar>\r
150 \r
151     </target>\r
152 \r
153     <!-- **************************************************************** -->\r
154     <!-- ***                                                          *** -->\r
155     <!-- ***                     Developer Tasks                      *** -->\r
156     <!-- ***                                                          *** -->\r
157     <!-- **************************************************************** -->\r
158         
159         <!-- Checks code against style guidelines -->
160         <target name="checkstyle" description="Developer task: Produces coding standard compliance report.">
161                 <mkdir dir="${reports.dir}" />
162                 
163                 <checkstyle config="${basedir}/checkstyle.xml"
164                                         failOnViolation="false"
165                         classpathref="build-path">
166                         <fileset dir="src" includes="**/*.java" />
167                         <formatter type="plain" toFile="${reports.dir}/checkstyle-report.txt" />
168                 </checkstyle>
169         </target>
170         \r
171     <!-- Create TGZ source distribution -->
172     <target name="tgz-src-dist" depends="package, javadoc" description="Developer task: Creates the tar, gzipped source distribution.">
173         <tar tarfile="${dist.dir}/${src-dist.name}.tgz" compression="gzip">
174                 <tarfileset dir="${build-lib.dir}" prefix="/build-lib/" />
175                 <tarfileset dir="${lib.dir}" prefix="/lib/" />
176                 <tarfileset dir="${resources.dir}" prefix="/resources/" />
177                 <tarfileset dir="${core-src.dir}" prefix="/src/" />
178                 <tarfileset dir="${test-src.dir}" prefix="/test/" />
179                 <tarfileset dir="${doc.dir}" prefix="/doc/" />
180                 <tarfileset file="${dist.dir}/${jar.name}" prefix="/dist/" />
181                 <tarfileset file="${basedir}/*.*" prefix="/" />
182         </tar>
183         <checksum file="${dist.dir}/${src-dist.name}.tgz" />
184     </target>
185
186     <!-- Create TGZ binary distribution -->
187     <target name="tgz-bin-dist" depends="package, javadoc" description="Developer task: Creates the tar, gzipped binary distribution.">
188         <tar tarfile="${dist.dir}/${bin-dist.name}.tgz" compression="gzip">
189                 <tarfileset dir="${lib.dir}" prefix="/lib/" />\r
190                 <tarfileset dir="${resources.dir}" prefix="/resources/" />
191                 <tarfileset dir="${doc.dir}" prefix="/doc/" />
192                 <tarfileset file="${dist.dir}/${jar.name}" prefix="/dist/" />
193         </tar>
194         <checksum file="${dist.dir}/${bin-dist.name}.tgz" />
195     </target>
196
197     <!-- Create ZIP source distribution -->
198     <target name="zip-src-dist" depends="package, javadoc" description="Developer task: Creates the zipped source distribution.">
199         <zip zipfile="${dist.dir}/${src-dist.name}.zip" whenempty="fail">
200                 <zipfileset dir="${build-lib.dir}" prefix="build-lib/" />
201                 <zipfileset dir="${lib.dir}" prefix="lib/" />\r
202                 <zipfileset dir="${resources.dir}" prefix="/resources/" />
203                 <zipfileset dir="${core-src.dir}" prefix="src/" />
204                 <zipfileset dir="${test-src.dir}" prefix="test/" />
205                 <zipfileset dir="${doc.dir}" prefix="doc/" />
206                 <zipfileset file="${dist.dir}/${jar.name}" prefix="/dist/" />
207                 <zipfileset file="${basedir}/*.*" prefix="" />
208         </zip>
209         <checksum file="${dist.dir}/${src-dist.name}.zip" />
210     </target>
211
212     <!-- Create ZIP binary distribution -->
213     <target name="zip-bin-dist" depends="package, javadoc"  description="Developer task: Creates the zipped binary distribution.">
214         <zip zipfile="${dist.dir}/${bin-dist.name}.zip" whenempty="fail">
215                 <zipfileset dir="${lib.dir}" prefix="lib/" />\r
216                 <zipfileset dir="${resources.dir}" prefix="/resources/" />
217                 <zipfileset dir="${doc.dir}" prefix="doc/" />
218                 <zipfileset file="${dist.dir}/${jar.name}" prefix="/dist/" />
219         </zip>
220         <checksum file="${dist.dir}/${bin-dist.name}.zip" />
221     </target>\r
222 \r
223 </project>