No need for special log4j exclusion rule in build
[java-idp.git] / build.xml
index 4881c7e..b4efd1a 100755 (executable)
--- a/build.xml
+++ b/build.xml
-<!-- Main build configutaion for Shibboleth java components - Walter Hoehn 06/04/2002 -->
-
-<project name="Shibboleth" default="dist-all" basedir=".">
-
-    <!-- Set global properties for this build -->
-    <property name="distname" value="shibboleth" />
-    <property name="root" value="." />
-    <property name="src" value="${root}/src" />
-    <property name="approot" value="${root}/webApplication" />
-    <property name="configroot" value="${root}/webAppConfig" />
-    <property name="build" value="${approot}/WEB-INF/classes" />
-    <property name="libdir" value="${approot}/WEB-INF/lib" />
-    <property name="buildlibs" value="${root}/lib" />
-    <property name="distlibs" value="${root}/lib" />
-    <property name="dist" value="${root}/dist" />
-    <property name="docs" value="${root}/docs" />
-    <property name="javadocs" value="${docs}/api" />
-
-    <property name="year" value="2002"/>
-    <property name="copyright" value="Copyright &#169; ${year} UCAID. All Rights Reserved."/>
-
-
-    <!-- Construct the CLASSPATH -->
-    <path id="build.path">
-        <pathelement path="${classpath}" />
-        <pathelement location="${build}" />
-        <fileset dir="${libdir}">
-            <include name="**/*.jar" />
-        </fileset>
-        <fileset dir="${buildlibs}">
-            <include name="**/*.jar" />
-        </fileset>
-    </path>
-
-
-    <!-- Prepare directory structure for project build-->
-    <target name="init">
-    <mkdir dir="${build}" />
-    <mkdir dir="${dist}" />
-    </target>
-
-
-    <!-- This target should be run before checking code into the repository -->
-    <target name="pre-checkin" depends="compile-all, test-all, clean-all" />
-
-
-    <!-- Compile classes and move them to ${build} -->
-    <target name="compile-all" depends="init">
-        <javac srcdir="${src}" destdir="${build}" includes="**/*.java" debug="on">
-            <classpath refid="build.path" />
-        </javac>
-        <copy todir="${build}/schemas">
-            <fileset dir="${src}/schemas"/>
-        </copy>
-        <copy todir="${build}/conf">
-            <fileset dir="${src}/conf"/>
-        </copy>
-    </target>
-
-
-       <!-- Generate API docs -->
-       <target name="javadocs">
-               <mkdir dir="${docs}" />
-               <mkdir dir="${javadocs}" />
-               <javadoc packagenames='edu.internet2.middleware.*'
-                       sourcepath='${src}' destdir='${javadocs}'
-                       author='true' version='true'
-                       windowtitle='Shibboleth Java API' doctitle='Shibboleth Java API'
-                       bottom='${copyright}'>
-                <classpath refid="build.path" />
-        </javadoc>
+<project name="Shibboleth Identity Provider" basedir="." default="install">
+       
+       <!-- User based property file that overrides any property below -->
+       <property file="${user.name}-build.properties" />
+
+       <!-- Project based property file -->
+       <property file="build.properties" />
+
+       <!-- Installation specific property file -->
+       <property file="install.properties" />
+
+       <!-- Load ant-contrib tasks -->
+       <taskdef resource="net/sf/antcontrib/antlib.xml" />
+
+       <!-- Load Checkstyle tasks -->
+       <taskdef resource="checkstyletask.properties" />
+
+       <!-- Classpath for building core classes-->
+       <path id="build-path">
+               <fileset dir="${build-lib.dir}" includes="**/*.jar" />
+               <fileset dir="${lib.dir}" includes="**/*.jar" />
+       </path>
+
+       <!-- Classpath for testing classes-->
+       <path id="test-path">
+               <path refid="build-path" />
+               <pathelement location="${core-classes.dir}" />
+               <pathelement location="${core-src.dir}" />
+               <pathelement location="${test-classes.dir}" />
+               <pathelement location="${test-classes.dir}/data" />
+               <pathelement location="${test-classes.dir}/log4j.xml" />
+               <pathelement location="${test-src.dir}" />
+               <pathelement location="${classpathres.dir}" />
+       </path>
+
+       <!-- Prepare directory structure for build -->
+       <target name="build-init">
+               <mkdir dir="${build.dir}" />
        </target>
 
        </target>
 
-    <!-- Create various product distributions and move them to ${dist} -->
-    <target name="dist" depends="dist-all" />
-    <target name="dist-all" depends="compile-all, test-all, package-all, clean-build" />
-    <target name="package-all">
-        <war warfile="${dist}/${distname}.war" webxml="${configroot}/all.xml" basedir="${approot}" update="no" />
-    </target>
-
-    <target name="dist-origin" depends="compile-all, test-origin, package-origin, clean-build" />
-    <target name="package-origin">
-        <war warfile="${dist}/${distname}.war" webxml="${configroot}/origin.xml" basedir="${approot}" update="no" />
-    </target>
-
-    <!-- Build utilities -->
-    <target name="build-util" depends="compile-all">
-        <jar jarfile="${distlibs}/shib-util.jar" basedir="${build}" />
-    </target>
-
-    <target name="dist-wayf" depends="compile-all, test-wayf, package-wayf, clean-build" />
-    <target name="package-wayf">
-        <war warfile="${dist}/${distname}-wayf.war" webxml="${configroot}/wayf.xml" basedir="${approot}" update="no" />
-    </target>
-
-
-    <!-- Cleanup after the build, test, and distribution processes -->
-    <target name="clean" depends="clean-all" />
-    <target name="clean-all" depends="clean-build, clean-dist, clean-test, clean-javadocs, clean-util" />
-    <target name="clean-build">
-        <delete dir="${build}" />
-    </target>
-    <target name="clean-test">
-        <delete>
-            <fileset dir="${root}">
-                <include name="**/TEST*.txt" />
-            </fileset>
-        </delete>
-    </target>
-    <target name="clean-dist">
-        <delete dir="${dist}" />
-    </target>
-       <target name="clean-javadocs">
-               <delete dir="${javadocs}" />
+       <!-- Compile core (non-test) classes -->
+       <target name="compile-core" depends="build-init, clean-compile">
+               <mkdir dir="${core-classes.dir}" />
+
+               <javac srcdir="${core-src.dir}" destdir="${core-classes.dir}" includes="**/*.java" debug="on" source="1.5">
+                       <classpath refid="build-path" />
+               </javac>
+
+       </target>
+
+       <!-- Compile unit test classes -->
+       <target name="compile-test" depends="compile-core">
+               <mkdir dir="${test-classes.dir}" />
+
+               <javac srcdir="${test-src.dir}" destdir="${test-classes.dir}" includes="**/*.java" debug="on" source="1.5">
+                       <classpath refid="test-path" />
+               </javac>
+
+       </target>
+
+       <!-- Compile and run unit tests -->
+       <target name="test" depends="compile-core, compile-test" description="Runs the unit tests for the project.">
+               <mkdir dir="${test-results.dir}" />
+
+               <echo message="Excuting unit tests using endorsed directory ${java.endorsed.dirs}" />
+               <junit printsummary="off"
+                      fork="yes"
+                      forkmode="once"
+                      haltonerror="false"
+                      haltonfailure="false"
+                      dir="${basedir}"
+                      errorproperty="testFailed">
+                       <jvmarg value="-Djava.endorsed.dirs=${java.endorsed.dirs}" />
+                       <classpath refid="test-path" />
+                       <formatter type="xml" />
+                       <batchtest todir="${test-results.dir}">
+                               <fileset dir="${test-classes.dir}">
+                                       <include name="**/*Test.class" />
+                               </fileset>
+                       </batchtest>
+               </junit>
+               <junitreport todir="${test-results.dir}">
+                       <fileset dir="${test-results.dir}">
+                               <include name="TEST-*.xml" />
+                       </fileset>
+                       <report format="frames" todir="${test-report.dir}" />
+               </junitreport>
+
+               <echo message="Test report available at ${test-report.dir}/index.html" />
+               <fail if="testFailed" message="Test failure; see ${test-report.dir}/index.html for more information." />
+       </target>
+
+       <!-- Javadoc core (non-test) classes -->
+       <target name="javadoc" description="Creates the JavaDoc documentatin for the project.">
+               <mkdir dir="${javadoc.dir}" />
+               <javadoc packagenames="org.opensaml.*"
+                        sourcepath="${core-src.dir}"
+                        destdir="${javadoc.dir}"
+                        author="false"
+                        version="true"
+                        windowtitle="${ant.project.name} ${version} Java API"
+                        doctitle="${ant.project.name} ${version} Java API"
+                        bottom="${copyright}"
+                        overview="${core-src.dir}/overview.html">
+                       <classpath refid="build-path" />
+               </javadoc>
+       </target>
+
+       <!-- Removes previously compiled files -->
+       <target name="clean-compile">
+               <delete dir="${build.dir}" />
+               <delete dir="${dist.dir}" />
+       </target>
+
+       <!-- Removes all build generated content -->
+       <target name="clean" depends="clean-compile" description="Removes any artifact produced by the build process.">
+               <delete dir="${javadoc.dir}" />
+               <delete dir="${reports.dir}" />
+               <delete dir="${dist.dir}" />
+       </target>
+
+       <!-- Create JAR file -->
+       <target name="package" depends="compile-core" description="Creates the project library jar file.">
+               <mkdir dir="${dist.dir}" />
+
+               <if>
+                       <equals arg1="${jdk.target}" arg2="1.4" />
+                       <then>
+                               <java classname="com.rc.retroweaver.Weaver">
+                                       <arg value="-source" />
+                                       <arg value="${core-classes.dir}" />
+                                       <classpath>
+                                               <fileset dir="${thirdpaty-lib.dir}">
+                                                       <include name="**/*.jar" />
+                                               </fileset>
+                                       </classpath>
+                               </java>
+
+                               <echo message="**************************************************************" />
+                               <echo message="    Remember, you must include the retroweaver-rt jar" />
+                               <echo message="    file, located in the thirdparty-lib directory, along with the" />
+                               <echo message="    ${jar.name} on your" />
+                               <echo message="    classpath in order to use this with JDK 1.4" />
+                               <echo message="**************************************************************" />
+
+                       </then>
+               </if>
+
+               <jar destfile="${dist.dir}/${jar.name}" whenempty="fail">
+                       <fileset dir="${classpathres.dir}" />
+                       <zipfileset dir="${metainf.dir}" prefix="META-INF/" />
+                       <zipfileset dir="${core-classes.dir}" />
+               </jar>
+
+       </target>
+
+       <target name="install" depends="package" description="Installs the identity provider software.">
+               <mkdir dir="${idp.home}" />
+               <mkdir dir="${idp.home}/lib" />
+               <mkdir dir="${idp.home}/conf" />
+               <mkdir dir="${idp.home}/logs" />
+               <mkdir dir="${idp.home}/bin" />
+               <mkdir dir="${idp.home}/war" />
+               <mkdir dir="${idp.home}/metadata" />
+
+               <copy todir="${idp.home}/lib" preservelastmodified="true">
+                       <fileset dir="${lib.dir}" />
+                       <fileset file="${dist.dir}/${jar.name}" />
+                       <fileset file="${build-lib.dir}/servlet-2.4.jar" />
+               </copy>
+               
+               <if>
+                       <available file="${idp.home}/conf" />
+                       <then>
+                               <mkdir dir="${idp.home}/conf.bak" />
+                               <copy todir="${idp.home}/conf.bak" preservelastmodified="true">
+                                       <fileset dir="${idp.home}/conf" />
+                               </copy>
+                       </then>
+               </if>
+
+               <copy todir="${idp.home}/conf" preservelastmodified="true" overwrite="${idp.overwrite-config}">
+                       <fileset dir="${conf.dir}" />
+                       <filterset begintoken="$" endtoken="$">
+                               <filter token="IDP_HOME" value="${idp.home}" />
+                               <filter token="IDP_VERSION" value="${version}" />
+                       </filterset>
+               </copy>
+
+               <copy todir="${idp.home}/bin" preservelastmodified="true">
+                       <fileset dir="${tools.dir}" />
+                       <filterset begintoken="$" endtoken="$">
+                               <filter token="IDP_HOME" value="${idp.home}" />
+                               <filter token="IDP_VERSION" value="${version}" />
+                       </filterset>
+               </copy>
+
+               <chmod file="${idp.home}/bin/*.sh" perm="+x" />
+
+               <copy todir="${webinf-temp.dir}">
+                       <fileset dir="${webinf.dir}" />
+                       <filterset begintoken="$" endtoken="$">
+                               <filter token="IDP_HOME" value="${idp.home}" />
+                               <filter token="IDP_VERSION" value="${version}" />
+                       </filterset>
+               </copy>
+               <jar destfile="${idp.home}/war/${war.name}" whenempty="fail">
+                       <zipfileset dir="${webinf-temp.dir}" prefix="WEB-INF/" />
+                       <zipfileset dir="${webpages.dir}" prefix="" />
+                       <zipfileset dir="${lib.dir}" prefix="WEB-INF/lib/" />
+                       <zipfileset file="${dist.dir}/${jar.name}" prefix="WEB-INF/lib/" />
+               </jar>
+
+       </target>
+
+       <!-- **************************************************************** -->
+       <!-- ***                                                          *** -->
+       <!-- ***                     Developer Tasks                      *** -->
+       <!-- ***                                                          *** -->
+       <!-- **************************************************************** -->
+
+       <!-- Checks code against style guidelines -->
+       <target name="checkstyle" description="Developer task: Produces coding standard compliance report.">
+               <mkdir dir="${reports.dir}" />
+
+               <checkstyle config="${basedir}/checkstyle.xml" failOnViolation="false" classpathref="build-path">
+                       <fileset dir="src" includes="**/*.java" />
+                       <formatter type="plain" toFile="${reports.dir}/checkstyle-report.txt" />
+               </checkstyle>
        </target>
        </target>
-    <target name="clean-util">
-        <delete>
-            <fileset dir="${buildlibs}">
-                <include name="shib-util.jar" />
-            </fileset>
-        </delete>
-    </target>
-
-    
-    <!-- Run automated tests on compiled code -->
-    <target name="test-all" depends="test-origin, test-wayf" />
-    <target name="test-origin" depends="test-common">
-        <junit printsummary="no" fork="yes" haltonfailure="yes" haltonerror="yes">
-            <classpath refid="build.path" />
-            <formatter type="plain" />
-            <test name="edu.internet2.middleware.shibboleth.aa.arp.ArpTests" />
-        </junit>
-    </target>
-    <target name="test-wayf" depends="test-common" />
-    <target name="test-common" depends="compile-all"/>
 
 </project>
 
 </project>