Update release notes
[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         <jar destfile="${dist.dir}/${jar.name}" whenempty="fail">
145             <fileset dir="${classpathres.dir}" />
146             <zipfileset dir="${metainf.dir}" prefix="META-INF/" />
147             <zipfileset dir="${core-classes.dir}" />
148         </jar>
149
150     </target>
151
152     <target name="install" description="Installs the identity provider software.">
153         <input message="Is this a new installation? Answering yes will overwrite your current configuration. [yes|no]"
154                addproperty="new.install"
155                defaultvalue="no" />
156
157         <if>
158             <equals arg1="${new.install}" arg2="yes" />
159             <then>
160                 <input message="Where should the Shibboleth Identity Provider software be installed? [default: ${idp.home}]"
161                        addproperty="idp.home.input"
162                        defaultvalue="${idp.home}" />
163                 <var name="idp.home" value="${idp.home.input}" />
164
165                 <input message="What is the hostname of the Shibboleth Identity Provider server? [default: ${idp.hostname}]"
166                        addproperty="idp.hostname.input"
167                        defaultvalue="${idp.hostname}" />
168                 <var name="idp.hostname" value="${idp.hostname.input}" />
169                 
170                 <input message="A keystore is about to be generated for you. Please enter a password that will be used to protect it."
171                        addproperty="idp.keystore.pass" />
172
173                 <propertyfile file="install.properties">
174                     <entry key="idp.home" value="${idp.home.input}" />
175                     <entry key="idp.hostname" value="${idp.hostname.input}" />
176                 </propertyfile>
177
178                 <mkdir dir="${idp.home}" />
179                 <mkdir dir="${idp.home}/bin" />
180                 <mkdir dir="${idp.home}/conf" />
181                 <mkdir dir="${idp.home}/credentials" />
182                 <mkdir dir="${idp.home}/lib" />
183                 <mkdir dir="${idp.home}/logs" />
184                 <mkdir dir="${idp.home}/metadata" />
185                 <mkdir dir="${idp.home}/war" />
186
187                 <var name="idp.entity.id" value="https://${idp.hostname}/idp/shibboleth" />
188
189                 <regexSplit input="${idp.hostname}" regex="^.*\.(.*\..*$)" addproperty="idp.scope" />
190
191                 <echo message="Generating signing and encryption key, certificate, and keystore. " />
192                 <selfSignedCert hostname="${idp.hostname}"
193                                 privateKeyFile="${idp.home}/credentials/idp.key"
194                                 certificateFile="${idp.home}/credentials/idp.crt"
195                                 keystoreFile="${idp.home}/credentials/idp.jks"
196                                 keystorePassword="${idp.keystore.pass}" />
197
198                 <copy todir="${idp.home}/bin" preservelastmodified="true">
199                     <fileset dir="${tools.dir}" />
200                     <filterset begintoken="$" endtoken="$">
201                         <filter token="IDP_HOME" value="${idp.home}" />
202                         <filter token="IDP_VERSION" value="${version}" />
203                     </filterset>
204                 </copy>
205                 <chmod file="${idp.home}/bin/*.sh" perm="+x" />
206
207                 <copy todir="${idp.home}/conf" preservelastmodified="true" overwrite="true">
208                     <fileset dir="${conf.dir}" />
209                     <filterset begintoken="$" endtoken="$">
210                         <filter token="IDP_HOME" value="${idp.home}" />
211                         <filter token="IDP_VERSION" value="${version}" />
212                         <filter token="IDP_ENTITY_ID" value="${idp.entity.id}" />
213                         <filter token="IDP_SCOPE" value="${idp.scope}" />
214                         <filter token="IDP_CERTIFICATE" value="${idp.cert}" />
215                         <filter token="IDP_HOSTNAME" value="${idp.hostname}" />
216                     </filterset>
217                 </copy>
218
219                 <stringFromFile input="${idp.home}/credentials/idp.crt" addProperty="idp.cert" />
220                 <regexSplit input="${idp.cert}"
221                             regex="\A.*-----\s((?:.*\s)*)-----END.*\Z"
222                             addproperty="idp.metadata.cert" />
223                 <copy todir="${idp.home}/metadata" preservelastmodified="true" overwrite="true">
224                     <fileset dir="${metadata.dir}" />
225                     <filterset begintoken="$" endtoken="$">
226                         <filter token="IDP_ENTITY_ID" value="${idp.entity.id}" />
227                         <filter token="IDP_SCOPE" value="${idp.scope}" />
228                         <filter token="IDP_CERTIFICATE" value="${idp.metadata.cert}" />
229                         <filter token="IDP_HOSTNAME" value="${idp.hostname}" />
230                     </filterset>
231                 </copy>
232             </then>
233         </if>
234
235         <copy todir="${idp.home}/lib" preservelastmodified="true">
236             <fileset dir="${lib.dir}" />
237             <fileset file="${dist.dir}/${jar.name}" />
238             <fileset file="${build-lib.dir}/servlet-2.4.jar" />
239         </copy>
240
241         <copy todir="${webinf-temp.dir}">
242             <fileset dir="${webinf.dir}" />
243             <filterset begintoken="$" endtoken="$">
244                 <filter token="IDP_HOME" value="${idp.home}" />
245                 <filter token="IDP_VERSION" value="${version}" />
246             </filterset>
247         </copy>
248
249         <jar destfile="${idp.home}/war/${war.name}" whenempty="fail">
250             <zipfileset dir="${webinf-temp.dir}" prefix="WEB-INF/" />
251             <zipfileset dir="${webpages.dir}" prefix="" />
252             <zipfileset dir="${lib.dir}" prefix="WEB-INF/lib/" />
253             <zipfileset file="${dist.dir}/${jar.name}" prefix="WEB-INF/lib/" />
254         </jar>
255     </target>
256
257
258     <!-- **************************************************************** -->
259     <!-- ***                                                          *** -->
260     <!-- ***                     Developer Tasks                      *** -->
261     <!-- ***                                                          *** -->
262     <!-- **************************************************************** -->
263
264     <!-- Checks code against style guidelines -->
265     <target name="checkstyle" description="Developer task: Produces coding standard compliance report.">
266         <mkdir dir="${reports.dir}" />
267
268         <checkstyle config="${basedir}/checkstyle.xml" failOnViolation="false" classpathref="build-path">
269             <fileset dir="src" includes="**/*.java" />
270             <formatter type="plain" toFile="${reports.dir}/checkstyle-report.txt" />
271         </checkstyle>
272     </target>
273
274 </project>