view apps/samples/Ensemble8/build.xml @ 10914:f29f3fbe6810

8198329: Support FX build / test using JDK that doesn't include javafx.* modules Reviewed-by: prr, jvos, aghaisas
author kcr
date Fri, 27 Apr 2018 05:19:35 -0700
parents 3932162186a7
children e1d1bb48b99a
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="Ensemble8" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
    <description>Builds, tests, and runs the project Ensemble8.</description>
    <import file="nbproject/build-impl.xml"/>
    <!--

    There exist several targets which are by default empty and which can be 
    used for execution of your tasks. These targets are usually executed 
    before and after some main targets. They are: 

      -pre-init:                 called before initialization of project properties
      -post-init:                called after initialization of project properties
      -pre-compile:              called before javac compilation
      -post-compile:             called after javac compilation
      -pre-compile-single:       called before javac compilation of single file
      -post-compile-single:      called after javac compilation of single file
      -pre-compile-test:         called before javac compilation of JUnit tests
      -post-compile-test:        called after javac compilation of JUnit tests
      -pre-compile-test-single:  called before javac compilation of single JUnit test
      -post-compile-test-single: called after javac compilation of single JUunit test
      -pre-jar:                  called before JAR building
      -post-jar:                 called after JAR building
      -post-clean:               called after cleaning build products

    (Targets beginning with '-' are not intended to be called on their own.)

    Example of inserting an obfuscator after compilation could look like this:

        <target name="-post-compile">
            <obfuscate>
                <fileset dir="${build.classes.dir}"/>
            </obfuscate>
        </target>

    For list of available properties check the imported 
    nbproject/build-impl.xml file. 


    Another way to customize the build is by overriding existing main targets.
    The targets of interest are: 

      -init-macrodef-javac:     defines macro for javac compilation
      -init-macrodef-junit:     defines macro for junit execution
      -init-macrodef-debug:     defines macro for class debugging
      -init-macrodef-java:      defines macro for class execution
      -do-jar-with-manifest:    JAR building (if you are using a manifest)
      -do-jar-without-manifest: JAR building (if you are not using a manifest)
      run:                      execution of project 
      -javadoc-build:           Javadoc generation
      test-report:              JUnit report generation

    An example of overriding the target for project execution could look like this:

        <target name="run" depends="Ensemble8-impl.jar">
            <exec dir="bin" executable="launcher.exe">
                <arg file="${dist.jar}"/>
            </exec>
        </target>

    Notice that the overridden target depends on the jar target and not only on 
    the compile target as the regular run target does. Again, for a list of available 
    properties which you can use, check the target you are overriding in the
    nbproject/build-impl.xml file. 

    -->
    <target name="-pre-init">
        <!-- exclude samples that are not part of the base JavaFX -->
        <condition property="excludes" value="ensemble/samples/language/swing/**">
            <isset property="JFX_CORE_ONLY"/>
        </condition>
    </target>

    <!-- COPY SAMPLE SRC TO BUILD DIR -->
    <target name="-pre-compile" depends="-copy-cssref,-copy-legal">
        <echo>Copying all sample source files to build dir</echo>
         <copy todir="${build.classes.dir}">
            <fileset dir="${basedir}/src/samples/java">
                <include name="**/samples/**/*.java"/>
                <include name="**/*.js"/> <!-- include javascript files -->
            </fileset>
        </copy>
    </target>

    <property name="javafx.scene.doc-files.dir" location="${basedir}/../../../modules/javafx.graphics/src/main/docs/javafx/scene/doc-files"/>
    <condition property="javafx.scene.doc-files.exists">
        <available file="${javafx.scene.doc-files.dir}" type="dir"/>
    </condition>

    <target name="-copy-cssref" if="javafx.scene.doc-files.exists">
    	<mkdir dir="${build.cssref.dir}"/>
    	<copy todir="${build.cssref.dir}">
    		<fileset dir="${javafx.scene.doc-files.dir}">
    			<include name="cssref.html"/>
    			<include name="cssexample1.png"/>
    			<include name="cssexample2.png"/>
    			<include name="fx_code_header.jpg"/>
    		</fileset>
    	</copy>
    	<replaceregexp
    		file="${build.cssref.dir}/cssref.html"
    		match="http://download.java.net/java/jdk9/docs/legal/cpyr.html"
    		replace="http://www.oracle.com/technetwork/java/javase/terms/license/oraclebsd-1603217.txt"
    		byline="true"/>
    </target>

    <target name="-copy-legal">
    	<mkdir dir="${build.legal.dir}"/>
    	<copy todir="${build.legal.dir}">
    		<fileset dir="${legal.dir}"/>
    	</copy>
    </target>

    <!-- DON'T INCLUDE COMPILE TIME CODE IN APP JAR -->
    <target name="-pre-jar">
        <delete dir="${build.classes.dir}/ensemble/compiletime"/>
    </target>

    <!-- COPY LIBS INTO JAR FILE: so that we have a simple single jar application -->
    <target name="-post-jar">
        <zip destfile="${dist.jar}" update="true">
            <!-- Rename license and notice file -->
            <mappedresources>
                <zipfileset src="${file.reference.lucene-core-7.1.0.jar}">
                    <include name="META-INF/LICENSE.txt"/>
                </zipfileset>
                <globmapper from="*/LICENSE.txt" to="*/LUCENE_LICENSE.TXT" />
            </mappedresources>
            <mappedresources>
                <zipfileset src="${file.reference.lucene-core-7.1.0.jar}">
                    <include name="META-INF/NOTICE.txt"/>
                </zipfileset>
                <globmapper from="*/NOTICE.txt" to="*/LUCENE_NOTICE.TXT" />
            </mappedresources>

            <!-- Include the core SPI services -->
            <zipfileset src="${file.reference.lucene-core-7.1.0.jar}">
                <include name="META-INF/services/**"/>
            </zipfileset>

            <zipfileset src="${file.reference.lucene-core-7.1.0.jar}">
                <exclude name="META-INF/**"/>
            </zipfileset>
            <zipfileset src="${file.reference.lucene-grouping-7.1.0.jar}">
                <exclude name="META-INF/**"/>
            </zipfileset>
            <zipfileset src="${file.reference.lucene-queryparser-7.1.0.jar}">
                <exclude name="META-INF/**"/>
            </zipfileset>
        </zip>
    </target>

    <target name="ensemble-generate-samples-class" depends="init,compile" description="Ensemble: Generate source for all samples data class.">
       <java classname="ensemble.compiletime.EnsembleCompiletimeMain" fork="true">
         <arg value="samples"/>
         <classpath>
           <pathelement location="${build.classes.dir}"/>
           <pathelement path="${javac.classpath}"/>
         </classpath>
       </java>
    </target>
    
    <target name="ensemble-generate-search-index" depends="init,compile" description="Ensemble: Generate search index.">
       <delete dir="${basedir}/src/generated/ensemble/search/index"/>
       <java classname="ensemble.compiletime.EnsembleCompiletimeMain" fork="true">
         <arg value="index"/>
         <classpath>
           <pathelement location="${build.classes.dir}"/>
           <pathelement path="${javac.classpath}"/>
         </classpath>
       </java>
    </target>
    
</project>