Minor default config file changes
[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 Internet2 ant extensions -->
16     <taskdef resource="edu/internet2/middleware/ant/antlib.xml" />
17
18     <!-- Load Checkstyle tasks -->
19     <taskdef resource="checkstyletask.properties" />
20
21     <!-- Classpath for building core classes-->
22     <path id="build-path">
23         <fileset dir="${build-lib.dir}" includes="**/*.jar" />
24         <fileset dir="${lib.dir}" includes="**/*.jar" />
25     </path>
26
27     <!-- Classpath for testing classes-->
28     <path id="test-path">
29         <path refid="build-path" />
30         <pathelement location="${core-classes.dir}" />
31         <pathelement location="${core-src.dir}" />
32         <pathelement location="${test-classes.dir}" />
33         <pathelement location="${test-classes.dir}/data" />
34         <pathelement location="${test-classes.dir}/log4j.xml" />
35         <pathelement location="${test-src.dir}" />
36         <pathelement location="${classpathres.dir}" />
37     </path>
38
39     <!-- Prepare directory structure for build -->
40     <target name="build-init">
41         <mkdir dir="${build.dir}" />
42     </target>
43
44     <!-- Compile core (non-test) classes -->
45     <target name="compile-core" depends="build-init, clean-compile">
46         <mkdir dir="${core-prep-source.dir}" />
47         <mkdir dir="${core-classes.dir}" />
48
49         <copy todir="${core-prep-source.dir}" preservelastmodified="true">
50             <fileset dir="${core-src.dir}" />
51             <filterset begintoken="$" endtoken="$">
52                 <filter token="IDP_HOME" value="${idp.home}" />
53                 <filter token="IDP_VERSION" value="${version}" />
54             </filterset>
55         </copy>
56
57         <javac srcdir="${core-prep-source.dir}"
58                destdir="${core-classes.dir}"
59                includes="**/*.java"
60                debug="on"
61                source="1.5">
62             <classpath refid="build-path" />
63         </javac>
64
65         <delete dir="${core-prep-source.dir}" />
66
67     </target>
68
69     <!-- Compile unit test classes -->
70     <target name="compile-test" depends="compile-core">
71         <mkdir dir="${test-classes.dir}" />
72
73         <javac srcdir="${test-src.dir}" destdir="${test-classes.dir}" includes="**/*.java" debug="on" source="1.5">
74             <classpath refid="test-path" />
75         </javac>
76
77     </target>
78
79     <!-- Compile and run unit tests -->
80     <target name="test" depends="compile-core, compile-test" description="Runs the unit tests for the project.">
81         <mkdir dir="${test-results.dir}" />
82
83         <echo message="Excuting unit tests using endorsed directory ${java.endorsed.dirs}" />
84         <junit printsummary="off"
85                fork="yes"
86                forkmode="once"
87                haltonerror="false"
88                haltonfailure="false"
89                dir="${basedir}"
90                errorproperty="testFailed">
91             <jvmarg value="-Djava.endorsed.dirs=${java.endorsed.dirs}" />
92             <classpath refid="test-path" />
93             <formatter type="xml" />
94             <batchtest todir="${test-results.dir}">
95                 <fileset dir="${test-classes.dir}">
96                     <include name="**/*Test.class" />
97                 </fileset>
98             </batchtest>
99         </junit>
100         <junitreport todir="${test-results.dir}">
101             <fileset dir="${test-results.dir}">
102                 <include name="TEST-*.xml" />
103             </fileset>
104             <report format="frames" todir="${test-report.dir}" />
105         </junitreport>
106
107         <echo message="Test report available at ${test-report.dir}/index.html" />
108         <fail if="testFailed" message="Test failure; see ${test-report.dir}/index.html for more information." />
109     </target>
110
111     <!-- Javadoc core (non-test) classes -->
112     <target name="javadoc" description="Creates the JavaDoc documentatin for the project.">
113         <mkdir dir="${javadoc.dir}" />
114         <javadoc packagenames="org.opensaml.*"
115                  sourcepath="${core-src.dir}"
116                  destdir="${javadoc.dir}"
117                  author="false"
118                  version="true"
119                  windowtitle="${ant.project.name} ${version} Java API"
120                  doctitle="${ant.project.name} ${version} Java API"
121                  bottom="${copyright}"
122                  overview="${core-src.dir}/overview.html">
123             <classpath refid="build-path" />
124         </javadoc>
125     </target>
126
127     <!-- Removes previously compiled files -->
128     <target name="clean-compile">
129         <delete dir="${build.dir}" />
130         <delete dir="${dist.dir}" />
131     </target>
132
133     <!-- Removes all build generated content -->
134     <target name="clean" depends="clean-compile" description="Removes any artifact produced by the build process.">
135         <delete dir="${javadoc.dir}" />
136         <delete dir="${reports.dir}" />
137         <delete dir="${dist.dir}" />
138     </target>
139
140     <!-- Create JAR file -->
141     <target name="package" depends="compile-core" description="Creates the project library jar file.">
142         <mkdir dir="${dist.dir}" />
143
144         <if>
145             <equals arg1="${jdk.target}" arg2="1.4" />
146             <then>
147                 <java classname="com.rc.retroweaver.Weaver">
148                     <arg value="-source" />
149                     <arg value="${core-classes.dir}" />
150                     <classpath>
151                         <fileset dir="${thirdpaty-lib.dir}">
152                             <include name="**/*.jar" />
153                         </fileset>
154                     </classpath>
155                 </java>
156
157                 <echo message="**************************************************************" />
158                 <echo message="    Remember, you must include the retroweaver-rt jar" />
159                 <echo message="    file, located in the thirdparty-lib directory, along with the" />
160                 <echo message="    ${jar.name} on your" />
161                 <echo message="    classpath in order to use this with JDK 1.4" />
162                 <echo message="**************************************************************" />
163
164             </then>
165         </if>
166
167         <jar destfile="${dist.dir}/${jar.name}" whenempty="fail">
168             <fileset dir="${classpathres.dir}" />
169             <zipfileset dir="${metainf.dir}" prefix="META-INF/" />
170             <zipfileset dir="${core-classes.dir}" />
171         </jar>
172
173     </target>
174
175     <target name="install" description="Installs the identity provider software.">
176         <input message="Is this a new installation? Answering yes will overwrite your current configuration. [yes|no]"
177                addproperty="new.install"
178                defaultvalue="no" />
179
180         <if>
181             <equals arg1="${new.install}" arg2="yes" />
182             <then>
183                 <input message="Where should the Shibboleth Identity Provider software be installed? [default: ${idp.home}]"
184                        addproperty="idp.home.input"
185                        defaultvalue="${idp.home}" />
186                 <var name="idp.home" value="${idp.home.input}" />
187
188                 <input message="What is the hostname of the Shibboleth Identity Provider server? [default: ${idp.hostname}]"
189                        addproperty="idp.hostname.input"
190                        defaultvalue="${idp.hostname}" />
191                 <var name="idp.hostname" value="${idp.hostname.input}" />
192
193                 <propertyfile file="build.properties">
194                     <entry key="idp.home" value="${idp.home.input}" />
195                     <entry key="idp.hostname" value="${idp.hostname.input}" />
196                 </propertyfile>
197
198                 <mkdir dir="${idp.home}" />
199                 <mkdir dir="${idp.home}/bin" />
200                 <mkdir dir="${idp.home}/conf" />
201                 <mkdir dir="${idp.home}/credentials" />
202                 <mkdir dir="${idp.home}/lib" />
203                 <mkdir dir="${idp.home}/logs" />
204                 <mkdir dir="${idp.home}/metadata" />
205                 <mkdir dir="${idp.home}/war" />
206
207                 <var name="idp.entity.id" value="https://${idp.hostname}/idp/shibboleth" />
208
209                 <regexSplit input="${idp.hostname}" regex="^.*\.(.*\..*$)" addproperty="idp.scope" />
210
211                 <echo message="Generating signing and encryption key and certificate. " />
212                 <selfSignedCert hostname="${idp.hostname}"
213                                 privateKeyFile="${idp.home}/credentials/idp.key"
214                                 certificateFile="${idp.home}/credentials/idp.crt" />
215
216                 <copy todir="${idp.home}/bin" preservelastmodified="true">
217                     <fileset dir="${tools.dir}" />
218                     <filterset begintoken="$" endtoken="$">
219                         <filter token="IDP_HOME" value="${idp.home}" />
220                         <filter token="IDP_VERSION" value="${version}" />
221                     </filterset>
222                 </copy>
223                 <chmod file="${idp.home}/bin/*.sh" perm="+x" />
224
225                 <copy todir="${idp.home}/conf" preservelastmodified="true" overwrite="true">
226                     <fileset dir="${conf.dir}" />
227                     <filterset begintoken="$" endtoken="$">
228                         <filter token="IDP_HOME" value="${idp.home}" />
229                         <filter token="IDP_VERSION" value="${version}" />
230                         <filter token="IDP_ENTITY_ID" value="${idp.entity.id}" />
231                         <filter token="IDP_SCOPE" value="${idp.scope}" />
232                         <filter token="IDP_CERTIFICATE" value="${idp.cert}" />
233                         <filter token="IDP_HOSTNAME" value="${idp.hostname}" />
234                     </filterset>
235                 </copy>
236
237                 <stringFromFile input="${idp.home}/credentials/idp.crt" addProperty="idp.cert" />
238                 <regexSplit input="${idp.cert}"
239                             regex="\A.*-----\s((?:.*\s)*)-----END.*\Z"
240                             addproperty="idp.metadata.cert" />
241                 <copy todir="${idp.home}/metadata" preservelastmodified="true" overwrite="true">
242                     <fileset dir="${metadata.dir}" />
243                     <filterset begintoken="$" endtoken="$">
244                         <filter token="IDP_ENTITY_ID" value="${idp.entity.id}" />
245                         <filter token="IDP_SCOPE" value="${idp.scope}" />
246                         <filter token="IDP_CERTIFICATE" value="${idp.metadata.cert}" />
247                         <filter token="IDP_HOSTNAME" value="${idp.hostname}" />
248                     </filterset>
249                 </copy>
250             </then>
251         </if>
252
253         <copy todir="${idp.home}/lib" preservelastmodified="true">
254             <fileset dir="${lib.dir}" />
255             <fileset file="${dist.dir}/${jar.name}" />
256             <fileset file="${build-lib.dir}/servlet-2.4.jar" />
257         </copy>
258
259         <copy todir="${webinf-temp.dir}">
260             <fileset dir="${webinf.dir}" />
261             <filterset begintoken="$" endtoken="$">
262                 <filter token="IDP_HOME" value="${idp.home}" />
263                 <filter token="IDP_VERSION" value="${version}" />
264             </filterset>
265         </copy>
266
267         <jar destfile="${idp.home}/war/${war.name}" whenempty="fail">
268             <zipfileset dir="${webinf-temp.dir}" prefix="WEB-INF/" />
269             <zipfileset dir="${webpages.dir}" prefix="" />
270             <zipfileset dir="${lib.dir}" prefix="WEB-INF/lib/" />
271             <zipfileset file="${dist.dir}/${jar.name}" prefix="WEB-INF/lib/" />
272         </jar>
273     </target>
274
275
276     <!-- **************************************************************** -->
277     <!-- ***                                                          *** -->
278     <!-- ***                     Developer Tasks                      *** -->
279     <!-- ***                                                          *** -->
280     <!-- **************************************************************** -->
281
282     <!-- Checks code against style guidelines -->
283     <target name="checkstyle" description="Developer task: Produces coding standard compliance report.">
284         <mkdir dir="${reports.dir}" />
285
286         <checkstyle config="${basedir}/checkstyle.xml" failOnViolation="false" classpathref="build-path">
287             <fileset dir="src" includes="**/*.java" />
288             <formatter type="plain" toFile="${reports.dir}/checkstyle-report.txt" />
289         </checkstyle>
290     </target>
291
292 </project>