Skip to main content

Source code file content

Revision: 12242

Fixes https://java.net/jira/browse/JAVASERVERFACES-2895, make sure milliseconds are not taken into account when comparing If-Modified-Since against a resource
» Project Revision History

» Checkout URL

svn / trunk / build.xml

Size: 26945 bytes, 1 line
<?xml version='1.0' encoding='UTF-8'?>
<!--

    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

    Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.

    The contents of this file are subject to the terms of either the GNU
    General Public License Version 2 only ("GPL") or the Common Development
    and Distribution License("CDDL") (collectively, the "License").  You
    may not use this file except in compliance with the License.  You can
    obtain a copy of the License at
    https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    or packager/legal/LICENSE.txt.  See the License for the specific
    language governing permissions and limitations under the License.

    When distributing the software, include this License Header Notice in each
    file and include the License file at packager/legal/LICENSE.txt.

    GPL Classpath Exception:
    Oracle designates this particular file as subject to the "Classpath"
    exception as provided by Oracle in the GPL Version 2 section of the License
    file that accompanied this code.

    Modifications:
    If applicable, add the following below the License Header, with the fields
    enclosed by brackets [] replaced by your own identifying information:
    "Portions Copyright [year] [name of copyright owner]"

    Contributor(s):
    If you wish your version of this file to be governed by only the CDDL or
    only the GPL Version 2, indicate your decision by adding "[Contributor]
    elects to include this software in this distribution under the [CDDL or GPL
    Version 2] license."  If you don't indicate a single choice of license, a
    recipient has the option to distribute your version of this file under
    either the CDDL, the GPL Version 2 or to extend the choice of license to
    its licensees as provided above.  However, if you add GPL Version 2 code
    and therefore, elected the GPL Version 2 license, then the option applies
    only if the new code is made subject to such option by the copyright
    holder.

-->

<!-- ************ JSF build file ************************************** -->

<project name="mojarra" default="main" basedir=".">

    <!-- ************ Per user local properties ******************************* -->

    <property file="build.properties"/>
    <property environment="myenv"/>
    <import file="${jsf.build.home}/common/ant/common.xml"/>
    <property name="tasks.home" value="${myenv.TASKS_HOME}"/>
    <property name="dist.dir" value="${basedir}/dist"/>


    <property name="LICENSEFILE"
              value="${basedir}/legal/jsf-cddl/LICENSE.txt"/>

    <!-- ************ Compiler Defaults *************************************** -->


    <!-- ************ Executable Targets ************************************** -->
    
    <macrodef name="call.modules">
        <attribute name="target"/>
        <sequential>
            <if>
                <equals arg1="clean" arg2="@{target}" />
                <then>
                    <jsf.mvn dir="${basedir}/jsf-tools" goals="@{target}" />
                    <subant target="@{target}" inheritAll="false">
                      <property name="force.no.cluster" value="${force.no.cluster}" />
                      <filelist dir="${api.dir}">
                          <file name="build-pre-maven-rename.xml"/>
                      </filelist>    
                      <filelist dir="${impl.dir}">
                          <file name="build-pre-maven-rename.xml"/>
                      </filelist>
                  </subant>
                </then>
            </if>
            <if>
                <equals arg1="main" arg2="@{target}" />
                <then>
                    <jsf.mvn dir="${basedir}/jsf-tools" goals="install" />
                </then>
            </if>
            <subant target="@{target}" inheritAll="false">
                <property name="force.no.cluster" value="${force.no.cluster}" />
                <filelist dir="${api.dir}">
                    <file name="build.xml"/>
                </filelist>    
                <filelist dir="${impl.dir}">
                    <file name="build.xml"/>
                </filelist>
            </subant>
        </sequential>
    </macrodef>

    <target name="clean"
            description="Clean build and distribution directories">       
        <subant target="clean" inheritAll="false">
          <filelist dir="${regression.test.dir}">
            <file name="build.xml"/>
          </filelist>
        </subant>
        <delete file="mojarra-samples.zip"/>
        <delete dir="${basedir}/build"/>
        <delete dir="${dist.dir}"/>
        <call.modules target="clean"/>        
        <ant dir="jsf-demo" target="clean" />
        <ant dir="updatecenter2" target="updatecenter2.clean" />
    </target>  

    <target name="clean.mojarra.only"
            description="Clean just the Mojarra code">       
        <subant target="clean" inheritAll="false">
          <filelist dir="${jsf.build.home}">
            <file name="jsf-api/build.xml" />
            <file name="jsf-ri/build.xml" />
          </filelist>
        </subant>
    </target>  

    <target name="main" description="Build Mojarra">
        <call.modules target="main"/>
    </target>

    <target name="impl" description="Just build jsf-ri">
      <ant dir="jsf-ri" target="main" />
    </target>

    <target name="main.from.source" description="Build Mojarra, including some dependencies">
       <subant target="main" inheritAll="false">
            <property name="build.source" value="true"/>
            <filelist dir="${api.dir}">
                <file name="build.xml"/>
            </filelist>
            <filelist dir="${impl.dir}">
                <file name="build.xml"/>
            </filelist>
        </subant>
    </target>

    <target name="test" description="Run API, Impl, and Demo automated tests">
        <call.modules target="test"/>
        <subant target="test" inheritAll="false" failonerror="true">
          <filelist dir="${regression.test.dir}">
              <file name="build.xml"/>
          </filelist>
        </subant>

    </target>

    <target name="test.with.cactus.tests" description="Run API, Impl, and Demo automated tests">
        <call.modules target="test"/>
        <subant target="run.cactus.test" inheritAll="false">
          <property name="force.no.cluster" value="${force.no.cluster}" />
          <filelist dir="${impl.dir}">
            <file name="build.xml"/>
          </filelist>
        </subant>
        <subant target="test" inheritAll="false" failonerror="true">
          <filelist dir="${regression.test.dir}">
              <file name="build.xml"/>
          </filelist>
        </subant>

    </target>


    <target name="test.with.container.refresh"
            description="Stop the target container, deploy the build artifacts, restart the container and test">
        <trycatch reference="exception_ref">
            <try>
                <container.stop/>
                <antcall target="container.deploy"/>
                <echo message="Successfully deployed JSF implementation to container." />
                <echo message="About to start container." />
                <container.start/>
                <echo message="Successfully started container." />
                <echo message="About to invoke tests." />
                <antcall target="test"/>

                <!-- taking jsf-demo out of the standard build/test loop
                     as one can't build the current source bundle as jsf-demo
                     isn't included
                <filelist dir="${demo.dir}">
                    <file name="build.xml"/>
                </filelist>
                     -->


                <echo message="Successfully invoked test." />

            </try>

            <catch>
               <property name="exception" refid="exception_ref" />
               <property name="message" value="Error in trycatch block:${line.separator}${exception}" />
               <echo message="${message}" />
               <fail message="${message}" />
            </catch>

            <finally>

                <echo message="About to stop container." />
                <container.stop/>

            </finally>
        </trycatch>

    </target>

    <target name="test.with.cactus.tests.with.container.refresh"
            description="Stop the target container, deploy the build artifacts, restart the container and test">
        <trycatch reference="exception_ref">
            <try>
                <container.stop/>
                <antcall target="container.deploy"/>
                <echo message="Successfully deployed JSF implementation to container." />
                <echo message="About to start container." />
                <container.start/>
                <echo message="Successfully started container." />
                <echo message="About to invoke tests." />
                <antcall target="test.with.cactus.tests"/>

                <!-- taking jsf-demo out of the standard build/test loop
                     as one can't build the current source bundle as jsf-demo
                     isn't included
                <filelist dir="${demo.dir}">
                    <file name="build.xml"/>
                </filelist>
                     -->

                <echo message="Successfully invoked test." />

            </try>

            <catch>
               <property name="exception" refid="exception_ref" />
               <property name="message" value="Error in trycatch block:${line.separator}${exception}" />
               <echo message="${message}" />
               <fail message="${message}" />
            </catch>

            <finally>

                <echo message="About to stop container." />
                <container.stop/>

            </finally>
        </trycatch>

    </target>


    <target name="smoketest.with.container.refresh"
            description="Stop the target container, deploy the build artifacts, restart the container and run systest with partial state saving enabled">
        <trycatch>
            <try>
                <container.stop/>
                <antcall target="container.deploy"/>
                <echo message="Successfully deployed JSF implementation to container." />
                <echo message="About to start container." />
                <container.start/>
                <echo message="Successfully started container." />
                <echo message="About to invoke tests." />
                <subant target="init.test" inheritAll="false">
                  <filelist dir="${impl.dir}">
                      <file name="build.xml"/>
                  </filelist>
                </subant>
                <subant target="compile.test" inheritAll="false">
                  <filelist dir="${impl.dir}">
                      <file name="build.xml"/>
                  </filelist>
                </subant>
                <subant target="test.partial.true" inheritAll="false">
                  <filelist dir="${impl.dir}/systest">
                      <file name="build.xml"/>
                  </filelist>
                </subant>
                <echo message="Successfully invoked test." />
            </try>
            <finally>
                <echo message="About to stop container." />
                <container.stop/>
            </finally>
        </trycatch>
    </target>

   <target name="generate.smoketest.reports">
      <property name="test.report.dir" value="${impl.dir}/build/test-reports" />
      <mkdir dir="${test.report.dir}" />
      <mkdir dir="${test.report.dir}/html" />
      <junitreport todir="${test.report.dir}">
        <fileset dir="${impl.dir}/testresults/systest">
          <include name="TEST-*.xml" />
        </fileset>
        <report format="frames" todir="${test.report.dir}/html" />
      </junitreport>
   </target>


    <target name="test.with.container.refresh.and.generate.reports"
            depends="test.with.container.refresh,generate.reports" />

    <target name="smoketest.with.container.refresh.and.generate.reports"
            depends="smoketest.with.container.refresh,generate.smoketest.reports" />

    <target name="generate.reports">
      <ant dir="jsf-ri" antfile="build.xml" target="generate.reports"/>
    </target>

    <target name="assert.expected.passed.test.count">
      <if>
        <isset property="expected.passed.test.count" />
        <then> 
<echo>perform the assertion</echo>
         <sequential>
           <property name="test.report.dir" 
                     value="${impl.dir}/build/test-reports" />
           <loadfile property="report.summary"
                     srcFile="${test.report.dir}/html/overview-summary.html" />
           <propertyregex property="actual.passed.test.count"
                          input="${report.summary}"
                          regexp="(?s)(.*)(href=.all-tests.html.>)([0-9]{1,6})(.*)"
                          select="\3"
           />
           <math result="passed.test.count.difference" datatype="int"
                 operation="subtract" 
                 operand1="${actual.passed.test.count}"
                 operand2="${expected.passed.test.count}" />
           <propertyregex property="actual.lessthan.expected"
                          input="${passed.test.count.difference}"
                          regexp="^-.*"
                          replace="actual.lessthan.expected" />
           <fail if="actual.lessthan.expected" status="-1"
                 message="
--JOB FAILED!-- Fewer than expected tests passed.  Expected: ${expected.passed.test.count} Actual: ${actual.passed.test.count}"/>
          </sequential>
        </then>
      </if>
    </target>

    <target name="build.and.debug" depends="clean, main"
            description="Clean, build, and deploy, restarting in debug mode">
        <trycatch>
                <try>
                    <container.stop/>
                    <antcall target="container.deploy"/>
                    <container.debug/>
                </try>
        </trycatch>
    </target>

    <!-- Create the source distribution -->
    <target name="jsf.source">                
        <zip destfile="${dist.dir}/mojarra-${impl.version}-source.zip">

            <zipfileset dir="${basedir}"
                        excludes="**/*.class,
                                  **/build.properties/**,
                                  **/CVS/**,
                                  **/build/javadocs/**,
                                  **/build/managed-bean-javadocs/**,
                                  **/build/classes/**,
                                  **/build/lib/**,
                                  **/build/generate/facesdoc/**,
                                  **/build/generate/last-generation,
                                  **/build/vdldocs/**,
                                  **/build/generate/last-taglib-generation,
                                  **/build/generate/conf/**,
                                  **/build/TAG*txt,
                                  **/dist/**,
                                  **/www/**,
                                  **/jsf-demo/**,
                                  **/dependencies/**,
                                  **/test-sqe/**,
                                  **/contrib/**,
                                  **/repo/**,
                                  **/updatecenter2/**,
                                  **/changebundle.txt,
                                  **/newfiles.zip
                                  **/HUDSON_INFORMATION.txt,
                                  **/INTEGRATING_WITH_V3.txt,
                                  **/PROMOTING_A_BUILD.txt,
                                  **/TESTING_A_BUILD.txt,
                                  **/docs/**"
                        prefix="mojarra-${impl.version}-source"/>
             <zipfileset dir="${basedir}"
                        includes="${basedir}/build.xml" prefix="mojarra-${impl.version}-source"/>

        </zip>
        
        <!-- create a special source bundle for GlassFish Java EE 5 docs -->
        <mkdir dir="${basedir}/srctemp/jsf-${spec.version}-javadoc-src/jsf-api/src"/>
            <copy todir="${basedir}/srctemp/jsf-${spec.version}-javadoc-src/jsf-api/src">
                <fileset dir="${api.dir}/src" excludes="**/CVS/**"/>
                <fileset dir="${api.dir}/build/generate" includes="**/javax/**"/>
            </copy>
            <jar destfile="${dist.dir}/glassfish-jsf-${impl.version}-src.jar"
                 basedir="${basedir}/srctemp"/>
        <delete dir="${basedir}/srctemp"/>
    </target>

   <target name="jsf.source.tlda">

     <delete failonerror="false" dir="${dist.dir}/srctemp"/>
     <mkdir dir="${dist.dir}/srctemp"/>
     <unzip src="${dist.dir}/mojarra-${impl.version}-source.zip"
            dest="${dist.dir}/srctemp"/>
     <get src="http://anybodys.us.oracle.com/java/javaee/Specs/JSF/README_TLDA.txt"
          dest="${dist.dir}/srctemp/mojarra-${impl.version}-source/legal/README_TLDA.txt" />
     <zip destfile="${dist.dir}/mojarra-${impl.version}-source-tlda.zip"
          basedir="${dist.dir}/srctemp"/>
     <delete failonerror="false" dir="${dist.dir}/srctemp"/>

   </target>

   <target name="dist" description="Build distribution files"
           depends="main">
        
        <mkdir dir="${dist.dir}" />

        <ant dir="${demo.dir}" 
             antfile="build.xml"
             target="dist" 
             inheritAll="false"/>

        <copy file="${demo.dir}/mojarra-${impl.version}.zip"
              tofile="${dist.dir}/mojarra-${impl.version}-binary.zip"/>
       
        <copy file="${demo.dir}/glassfish-jsf-${impl.version}.jar"
              todir="${dist.dir}"/>

        <delete file="${demo.dir}/glassfish-jsf-${impl.version}.jar"/>
        <delete file="${demo.dir}/mojarra-${impl.version}.zip"/>

        <ant target="jsf.source"/>

   </target>



   <target name="deploy.spec.locally" if="spec-eg-dir-available">

     <delete dir="${javaserverfaces-spec-eg.dir}/javadocs/spec-snapshot" />
     <mkdir dir="${javaserverfaces-spec-eg.dir}/javadocs/spec-snapshot" />
     <unzip src="${dist.dir}/jsf-spec-${spec.snapshot.version}-${build.number}.zip"
            dest="${javaserverfaces-spec-eg.dir}/javadocs/spec-snapshot"
            overwrite="true"/>
     <move todir="${javaserverfaces-spec-eg.dir}/javadocs/spec-snapshot">
       <fileset dir="${javaserverfaces-spec-eg.dir}/javadocs/spec-snapshot/jsf-spec-${spec.snapshot.version}-${build.number}">
         <include name="**/*.*" />
         <include name="**/*" />
       </fileset>
     </move>
     <delete dir="${javaserverfaces-spec-eg.dir}/javadocs/spec-snapshot/jsf-spec-${spec.snapshot.version}-${build.number}" />

   </target>

   <target name="build.spec.snapshot" depends="dist">

       <echo message="build.number: ${build.number}" />

       <available type="dir" file="${javaserverfaces-spec-eg.dir}"
                  property="spec-eg-dir-available" />

       <ant dir="${demo.dir}" target="copy.spec.pdf" />

       <echo message="Unzipping ${demo.dir}/dist/docs/mojarra-${impl.version}-documentation.zip to ${spec.snapshot.dir}" />
       <unzip src="${demo.dir}/dist/docs/mojarra-${impl.version}-documentation.zip"
              dest="${spec.snapshot.dir}" overwrite="true"/>

       <zip destfile="${dist.dir}/jsf-spec-${spec.snapshot.version}-${build.number}.zip">
            <zipfileset dir="${spec.snapshot.dir}"
                        prefix="jsf-spec-${spec.snapshot.version}-${build.number}"/>
        </zip>

       <antcall target="deploy.spec.locally" />

  </target>

    <target name="build.java.net"
            depends="dist"/>

    <target name="nightly" depends="build.java.net"
            description="update nightly build">
        <if>
            <available
                  file="${tasks.home}/javanettasks-1.0.13.jar"/>
            <then>
                <sequential>
                    <taskdef
                          resource="org/kohsuke/javanettasks.properties">
                        <classpath>
                            <pathelement
                                  location="${tasks.home}/javanettasks-1.0.13.jar"/>
                            <fileset dir="${tasks.home}/lib"
                                     includes="*.jar"/>
                        </classpath>
                    </taskdef>

                    <javaNetUpload projectName="javaserverfaces"
                                   toFile="/2.0 Nightly/mojarra-${impl.version}-binary.zip"
                                   fromFile="${dist.dir}/mojarra-${impl.version}-binary.zip"
                                   fileDescription="Mojarra ${impl.version.number} nightly binary bundle."
                                   overwrite="yes"/>


                    <javaNetUpload projectName="javaserverfaces"
                                   toFile="/2.0 Nightly/mojarra-${impl.version}-source.zip"
                                   fromFile="${dist.dir}/mojarra-${impl.version}-source.zip"
                                   fileDescription="Mojarra ${impl.version.number} nightly source bundle."
                                   overwrite="yes"/>
                    <echo message="Deploying javax.faces.jar snapshot to the java.net M2 repository..."/>
                    <ant antfile="${impl.dir}/build.xml" target="mvn.deploy.snapshot"/>
                </sequential>
            </then>
            <else>
                <fail message="Javanettasks version 1.0.13 is not available at the location referred by TASKS_HOME (${tasks.home}).  Ensure that the TASKS_HOME environment variable is properly set."/>
            </else>
        </if>
    </target>



    <target name="build.samples.zip" depends="main" description="Build the demo distribution">

        <ant dir="${demo.dir}"
             antfile="build.xml"
             target="main"
             inheritAll="false"/>
        <mkdir dir="samples"/>
        <copy todir="${basedir}/samples/jsf-samples"
              file="${demo.dir}/guessNumber/build/jsf-guessNumber.war"/>
        <copy todir="${basedir}/samples/jsf-samples"
              file="${demo.dir}/carstore/build/jsf-cardemo.war"/>
        <copy todir="${basedir}/samples/jsf-samples"
              file="${demo.dir}/components/build/jsf-components.war"/>
        <copy todir="${basedir}/samples/jsf-samples"
              file="${demo.dir}/webtier-sample/build/webtier-sample.war"/>
        <copy todir="${basedir}/samples/jsf-samples"
              file="${demo.dir}/renderkits/build/jsf-renderkits.war"/>

        <copy toFile="${basedir}/samples/jsf-samples/README.html"
              file="${impl.dir}/docs/samples.html"/>

        <copy toFile="${basedir}/samples/jsf-samples/License.txt"
              file="${LICENSEFILE}"/>
        <zip destfile="${basedir}/mojarra-samples.zip"
             basedir="${basedir}/samples"/>
        <delete dir="samples"/>

        <installerBuilder
              classFile="${dist.dir}/mojarra-samples.class"
              licenseFile="${LICENSEFILE}"
              zipFile="${basedir}/mojarra-samples.zip"/>
    </target>

    <target name="updatecenter2" depends="main">
      <copy file="jsf-ri/build/lib/javax.faces.jar" todir="updatecenter2/lib"/>
    </target>

    <target name="mvn.deploy.release.local">
      <call.modules target="mvn.deploy.release.local" />
    </target>

    <target name="mvn.deploy.snapshot.local">
      <call.modules target="mvn.deploy.snapshot.local" />
    </target>

    <target name="mvn.deploy.promoted.local">
      <call.modules target="mvn.deploy.promoted.local" />
    </target>

    <target name="mvn.deploy.release">
      <call.modules target="mvn.deploy.release" />
    </target>

    <target name="mvn.deploy.snapshot">
      <call.modules target="mvn.deploy.snapshot" />
    </target>

    <target name="mvn.deploy.promoted">
      <call.modules target="mvn.deploy.promoted" />
    </target>

    <target name="hudson.deploy">

      <ant inheritAll="true"
            target="mvn.deploy.${mojarra.build.type}${mojarra.build.local.or.blank}"
               dir="jsf-api" />
      <ant inheritAll="true"
            target="mvn.deploy.${mojarra.build.type}${mojarra.build.local.or.blank}"
               dir="jsf-ri" />

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="main"
               dir="jsf-api" />

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="mvn.pre-maven-rename.deploy.${mojarra.build.type}${mojarra.build.local.or.blank}"
               dir="jsf-api" />

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="main"
               dir="jsf-ri" />

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="mvn.pre-maven-rename.deploy.${mojarra.build.type}${mojarra.build.local.or.blank}"
               dir="jsf-ri" />



    </target>

    <target name="hudson.deploy.milestone">

      <ant inheritAll="true"
            target="mvn.deploy.${mojarra.build.type}${mojarra.build.local.or.blank}"
               dir="jsf-ri" />

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="main"
               dir="jsf-api" />

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="mvn.pre-maven-rename.deploy.${mojarra.build.type}${mojarra.build.local.or.blank}"
               dir="jsf-api" />

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="main"
               dir="jsf-ri" />

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="mvn.pre-maven-rename.deploy.${mojarra.build.type}${mojarra.build.local.or.blank}"
               dir="jsf-ri" />



    </target>


    <target name="blank" />


    <target name="mvn.pre-maven-rename.deploy.snapshot.local">

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="main"
               dir="jsf-api">
        <property name="skip.javadoc.jar"  value="true" />
      </ant>

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="mvn.pre-maven-rename.deploy.snapshot.local"
               dir="jsf-api">
        <property name="skip.javadoc.jar"  value="true" />
      </ant>

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="main"
               dir="jsf-ri" />

      <ant inheritAll="true"
            antfile="build-pre-maven-rename.xml"
            target="mvn.pre-maven-rename.deploy.snapshot.local"
               dir="jsf-ri" />
    </target>

</project>


 
 
Close
loading
Please Confirm
Close