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