samples/messagedigest/build.xml
changeset 44 716af5f2ebd1
parent 37 1b1a4a203bf2
child 47 f464a16d553a
     1.1 --- a/samples/messagedigest/build.xml	Sat Jun 14 09:51:45 2008 +0200
     1.2 +++ b/samples/messagedigest/build.xml	Sat Jun 14 09:52:23 2008 +0200
     1.3 @@ -1,69 +1,80 @@
     1.4  <?xml version="1.0" encoding="UTF-8"?>
     1.5 -<!-- You may freely edit this file. See commented blocks below for -->
     1.6 -<!-- some examples of how to customize the build. -->
     1.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
     1.8 -<project name="messagedigest" default="default" basedir=".">
     1.9 -    <description>Builds, tests, and runs the project messagedigest.</description>
    1.10 -    <import file="nbproject/build-impl.xml"/>
    1.11 -    <!--
    1.12 -
    1.13 -    There exist several targets which are by default empty and which can be 
    1.14 -    used for execution of your tasks. These targets are usually executed 
    1.15 -    before and after some main targets. They are: 
    1.16 -
    1.17 -      -pre-init:                 called before initialization of project properties
    1.18 -      -post-init:                called after initialization of project properties
    1.19 -      -pre-compile:              called before javac compilation
    1.20 -      -post-compile:             called after javac compilation
    1.21 -      -pre-compile-single:       called before javac compilation of single file
    1.22 -      -post-compile-single:      called after javac compilation of single file
    1.23 -      -pre-compile-test:         called before javac compilation of JUnit tests
    1.24 -      -post-compile-test:        called after javac compilation of JUnit tests
    1.25 -      -pre-compile-test-single:  called before javac compilation of single JUnit test
    1.26 -      -post-compile-test-single: called after javac compilation of single JUunit test
    1.27 -      -pre-jar:                  called before JAR building
    1.28 -      -post-jar:                 called after JAR building
    1.29 -      -post-clean:               called after cleaning build products
    1.30 -
    1.31 -    (Targets beginning with '-' are not intended to be called on their own.)
    1.32 -
    1.33 -    Example of inserting an obfuscator after compilation could look like this:
    1.34 -
    1.35 -        <target name="-post-compile">
    1.36 -            <obfuscate>
    1.37 -                <fileset dir="${build.classes.dir}"/>
    1.38 -            </obfuscate>
    1.39 -        </target>
    1.40 -
    1.41 -    For list of available properties check the imported 
    1.42 -    nbproject/build-impl.xml file. 
    1.43 -
    1.44 -
    1.45 -    Another way to customize the build is by overriding existing main targets.
    1.46 -    The targets of interest are: 
    1.47 -
    1.48 -      -init-macrodef-javac:     defines macro for javac compilation
    1.49 -      -init-macrodef-junit:     defines macro for junit execution
    1.50 -      -init-macrodef-debug:     defines macro for class debugging
    1.51 -      -init-macrodef-java:      defines macro for class execution
    1.52 -      -do-jar-with-manifest:    JAR building (if you are using a manifest)
    1.53 -      -do-jar-without-manifest: JAR building (if you are not using a manifest)
    1.54 -      run:                      execution of project 
    1.55 -      -javadoc-build:           Javadoc generation
    1.56 -      test-report:              JUnit report generation
    1.57 -
    1.58 -    An example of overriding the target for project execution could look like this:
    1.59 -
    1.60 -        <target name="run" depends="messagedigest-impl.jar">
    1.61 -            <exec dir="bin" executable="launcher.exe">
    1.62 -                <arg file="${dist.jar}"/>
    1.63 -            </exec>
    1.64 -        </target>
    1.65 -
    1.66 -    Notice that the overridden target depends on the jar target and not only on 
    1.67 -    the compile target as the regular run target does. Again, for a list of available 
    1.68 -    properties which you can use, check the target you are overriding in the
    1.69 -    nbproject/build-impl.xml file. 
    1.70 -
    1.71 -    -->
    1.72 +<project name="Build Script" default="test" basedir=".">
    1.73 +    <target name="clean">
    1.74 +        <delete dir="build"/>
    1.75 +    </target>
    1.76 +    
    1.77 +    <target name="build" depends="-libraries">
    1.78 +        <antcall target="-build-one">
    1.79 +            <param name="version" value="new-api"/>
    1.80 +        </antcall>
    1.81 +        <antcall target="-build-one">
    1.82 +            <param name="version" value="new-spi"/>
    1.83 +            <param name="cp" value="build/new-api/classes"/>
    1.84 +        </antcall>
    1.85 +        <antcall target="-build-one">
    1.86 +            <param name="version" value="bridge"/>
    1.87 +            <param name="cp" value="build/new-api/classes:build/new-spi/classes"/>
    1.88 +        </antcall>
    1.89 +        
    1.90 +        <antcall target="-build-one">
    1.91 +            <param name="version" value="test"/>
    1.92 +            <param name="cp" value="build/new-api/classes:build/new-spi/classes:${junit.jar}"/>
    1.93 +        </antcall>
    1.94 +    </target>
    1.95 +    
    1.96 +    <target name="test" depends="build">
    1.97 +        <echo level="info" message="Running the tests with bridge enabled. This should succeeds."/>
    1.98 +        <antcall target="-run-one">
    1.99 +            <param name="test.cp" value="build/new-api/classes:build/new-spi/classes:build/bridge/classes"/>
   1.100 +        </antcall>
   1.101 +        <echo level="info" message="Running the tests without bridge module. This should fail."/>
   1.102 +        <antcall target="-run-one">
   1.103 +            <param name="test.cp" value="build/new-api/classes:build/new-spi/classes"/>
   1.104 +        </antcall>
   1.105 +    </target>
   1.106 +    
   1.107 +    <!-- support methods -->
   1.108 +    
   1.109 +    <target name="-libraries">
   1.110 +        <ant dir="../libs/"/>
   1.111 +        
   1.112 +        <property name="junit.jar" location="../libs/dist/junit-4.4.jar"/>
   1.113 +    </target>
   1.114 +    
   1.115 +    <target name="-run-one">
   1.116 +        <mkdir dir="build/testresults"/>
   1.117 +        <junit dir="build/test/classes" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
   1.118 +            <batchtest todir="build/testresults">
   1.119 +                <fileset dir="build/test/classes">
   1.120 +                    <filename name="**/*Test.class"/>
   1.121 +                </fileset>
   1.122 +            </batchtest>
   1.123 +            <classpath>
   1.124 +                <path path="${test.cp}"/>
   1.125 +                <path location="build/test/classes"/>
   1.126 +                <path location="${junit.jar}"/>
   1.127 +            </classpath>
   1.128 +            <formatter type="brief" usefile="false"/>
   1.129 +            <formatter type="xml"/>
   1.130 +        </junit>
   1.131 +    </target>
   1.132 +    
   1.133 +    <target name="-build-one">
   1.134 +        <fail message="You need to specify version number" unless="version"/>
   1.135 +        
   1.136 +        <mkdir dir="build/${version}/classes"/>
   1.137 +        <property name="cp" value=""/>
   1.138 +        <javac 
   1.139 +            srcdir="src-${version}" 
   1.140 +            destdir="build/${version}/classes" 
   1.141 +            source="1.5" target="1.5"
   1.142 +            classpath="${cp}"
   1.143 +        />
   1.144 +        <copy todir="build/${version}/classes">
   1.145 +            <fileset dir="src-${version}">
   1.146 +                <exclude name="**/*.java"/>
   1.147 +            </fileset>
   1.148 +        </copy>
   1.149 +    </target>
   1.150  </project>