samples/livedb/build.xml
author Jaroslav Tulach <jtulach@netbeans.org>
Fri, 30 Jul 2010 14:14:55 +0200
changeset 364 088d9d560bda
parent 359 9d430d9bc4b1
permissions -rw-r--r--
Rather make sure libraries are downloaded
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <!-- You may freely edit this file. See commented blocks below for -->
     3 <!-- some examples of how to customize the build. -->
     4 <!-- (If you delete it and reopen the project it will be recreated.) -->
     5 <!-- By default, only the Clean and Build commands use this build script. -->
     6 <!-- Commands such as Run, Debug, and Test only use this build script if -->
     7 <!-- the Compile on Save feature is turned off for the project. -->
     8 <!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
     9 <!-- in the project's Project Properties dialog box.-->
    10 <project name="livedb" default="default" basedir=".">
    11     <description>Builds, tests, and runs the project livedb.</description>
    12     <import file="nbproject/build-impl.xml"/>
    13 
    14     <ant dir="../libs/"/>
    15     <!--
    16 
    17     There exist several targets which are by default empty and which can be 
    18     used for execution of your tasks. These targets are usually executed 
    19     before and after some main targets. They are: 
    20 
    21       -pre-init:                 called before initialization of project properties
    22       -post-init:                called after initialization of project properties
    23       -pre-compile:              called before javac compilation
    24       -post-compile:             called after javac compilation
    25       -pre-compile-single:       called before javac compilation of single file
    26       -post-compile-single:      called after javac compilation of single file
    27       -pre-compile-test:         called before javac compilation of JUnit tests
    28       -post-compile-test:        called after javac compilation of JUnit tests
    29       -pre-compile-test-single:  called before javac compilation of single JUnit test
    30       -post-compile-test-single: called after javac compilation of single JUunit test
    31       -pre-jar:                  called before JAR building
    32       -post-jar:                 called after JAR building
    33       -post-clean:               called after cleaning build products
    34 
    35     (Targets beginning with '-' are not intended to be called on their own.)
    36 
    37     Example of inserting an obfuscator after compilation could look like this:
    38 
    39         <target name="-post-compile">
    40             <obfuscate>
    41                 <fileset dir="${build.classes.dir}"/>
    42             </obfuscate>
    43         </target>
    44 
    45     For list of available properties check the imported 
    46     nbproject/build-impl.xml file. 
    47 
    48 
    49     Another way to customize the build is by overriding existing main targets.
    50     The targets of interest are: 
    51 
    52       -init-macrodef-javac:     defines macro for javac compilation
    53       -init-macrodef-junit:     defines macro for junit execution
    54       -init-macrodef-debug:     defines macro for class debugging
    55       -init-macrodef-java:      defines macro for class execution
    56       -do-jar-with-manifest:    JAR building (if you are using a manifest)
    57       -do-jar-without-manifest: JAR building (if you are not using a manifest)
    58       run:                      execution of project 
    59       -javadoc-build:           Javadoc generation
    60       test-report:              JUnit report generation
    61 
    62     An example of overriding the target for project execution could look like this:
    63 
    64         <target name="run" depends="livedb-impl.jar">
    65             <exec dir="bin" executable="launcher.exe">
    66                 <arg file="${dist.jar}"/>
    67             </exec>
    68         </target>
    69 
    70     Notice that the overridden target depends on the jar target and not only on 
    71     the compile target as the regular run target does. Again, for a list of available 
    72     properties which you can use, check the target you are overriding in the
    73     nbproject/build-impl.xml file. 
    74 
    75     -->
    76     
    77     <target name="-pre-compile-test">
    78         <antcall target="create-db"/>
    79     </target>
    80     
    81     <!-- BEGIN: livedb.derby.create -->
    82     <target name="-check-db">
    83         <property name="db" location="build/classes/db"/>
    84         <available property="db.exists" file="${db}"/>
    85     </target>
    86     <target name="create-db" unless="db.exists" depends="init,-check-db">
    87         <mkdir dir="${db}"/>
    88         <delete dir="${db}"/>
    89         <echo message="Creating DB in ${db}"/>
    90         <sql classpath="${file.reference.derby.jar}" userid="j1" password="j1" 
    91             url="jdbc:derby:${db};create=true" 
    92             driver="org.apache.derby.jdbc.EmbeddedDriver"
    93         >
    94         create table APP.AGE (
    95             NAME VARCHAR(30),
    96             AGE NUMERIC(3)
    97         );
    98         insert into APP.AGE values ('apidesign', 3);
    99         </sql>
   100         <!-- don't forget to shutdown the DB -->
   101         <sql classpath="${file.reference.derby.jar}" userid="j1" password="j1" 
   102             url="jdbc:derby:${db};shutdown=true" 
   103             driver="org.apache.derby.jdbc.EmbeddedDriver" 
   104             onerror="continue"
   105             errorproperty="ignore.error" 
   106             failonconnectionerror="false"
   107         >none</sql>
   108         <echo message="DB created OK."/>
   109     </target>
   110     <!-- END: livedb.derby.create -->
   111 </project>