buildframework/helium/external/helium-antlib/macros.ant.xml
changeset 307 22ecbfc20eb4
parent 215 b61c19d4168d
parent 217 0f5e3a7fb6af
child 308 7830b8253b5a
equal deleted inserted replaced
215:b61c19d4168d 307:22ecbfc20eb4
     1 <?xml version="1.0"?>
       
     2 <!-- 
       
     3 ============================================================================ 
       
     4 Name        : macros.xml 
       
     5 Part of     : Helium AntLib
       
     6 
       
     7 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     8 All rights reserved.
       
     9 This component and the accompanying materials are made available
       
    10 under the terms of the License "Eclipse Public License v1.0"
       
    11 which accompanies this distribution, and is available
       
    12 at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    13 
       
    14 Initial Contributors:
       
    15 Nokia Corporation - initial contribution.
       
    16 
       
    17 Contributors:
       
    18 
       
    19 Description:
       
    20 
       
    21 ============================================================================
       
    22 -->
       
    23 <project name="build-macros" xmlns:au="org.apache.ant.antunit">
       
    24     <description>Helium Antlib build macro.</description>
       
    25     
       
    26     <dirname property="helium.antlib.root.dir" file="${ant.file.build-macros}" />
       
    27     <property name="build.temp.dir" location="${basedir}/../build" />
       
    28     <property name="bin.dir" location="${basedir}/../bin" />
       
    29 
       
    30     <path id="helium.antlib.classpath">
       
    31         <fileset dir="${helium.antlib.root.dir}/lib" includes="*.jar" />
       
    32         <fileset dir="${helium.antlib.root.dir}/antlibs" includes="*.jar" />
       
    33     </path>
       
    34     
       
    35     <taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="helium.antlib.classpath"/>
       
    36     <taskdef resource="org/apache/ant/antunit/antlib.xml" uri="org.apache.ant.antunit" classpathref="helium.antlib.classpath"/>
       
    37     
       
    38     
       
    39     <presetdef name="subantPreset">
       
    40         <subant failonerror="true">
       
    41             <resources refid="subant.build.files"/>
       
    42         </subant>
       
    43     </presetdef>
       
    44     
       
    45     
       
    46     <macrodef name="compileModule">
       
    47         <attribute name="name" />
       
    48         <attribute name="dir" default="${helium.antlib.root.dir}" />
       
    49         <sequential>
       
    50             <mkdir dir="${build.temp.dir}/@{name}/classes" />
       
    51             <javac srcdir="${basedir}/src" destdir="${build.temp.dir}/@{name}/classes"
       
    52                    debug="true" source="1.6" target="1.6">
       
    53                 <classpath refid="helium.antlib.classpath" />
       
    54                 <classpath refid="helium.@{name}.classpath" />
       
    55                 <include name="**/*.java" />
       
    56                 <compilerarg value="-Xlint:unchecked" />
       
    57                 <compilerarg value="-Xlint:deprecation" />
       
    58             </javac>
       
    59         </sequential>
       
    60     </macrodef>
       
    61 
       
    62     
       
    63     <macrodef name="jarModule">
       
    64         <attribute name="name" />
       
    65         <attribute name="dir" default="${helium.antlib.root.dir}" />
       
    66         <attribute name="bindir" default="${bin.dir}" />
       
    67         <sequential>
       
    68             <echo>Packaging module @{name}</echo>
       
    69             <mkdir dir="@{bindir}" />
       
    70             <jar destfile="@{bindir}/helium-@{name}.jar">
       
    71                 <fileset dir="${build.temp.dir}/@{name}/classes" />
       
    72                 <fileset dir="${basedir}/src" includes="**/*.xml" />
       
    73                 <fileset dir="${basedir}/src" includes="**/*.*ftl" />
       
    74 
       
    75                 <manifest>
       
    76                     <section name="common">
       
    77                         <attribute name="Implementation-Title" value="@{name}" />
       
    78                         <attribute name="Implementation-Vendor" value="Nokia" />
       
    79                     </section>
       
    80                 </manifest>
       
    81             </jar>
       
    82         </sequential>
       
    83     </macrodef>
       
    84     
       
    85 
       
    86     <macrodef name="testModule">
       
    87         <attribute name="name" />
       
    88         <attribute name="dir" default="${helium.antlib.root.dir}" />
       
    89         <sequential>
       
    90             <if>
       
    91                 <available type="dir" file="${basedir}/tests"/>
       
    92                 <then>
       
    93                     <exec osfamily="windows" executable="cmd" dir="${basedir}/tests">
       
    94                         <env key="ANT_LIB_HOME" path="${helium.antlib.root.dir}"/>
       
    95                         <arg line="/c build.bat unittest" />
       
    96                     </exec>
       
    97                     <exec osfamily="unix" executable="./bld.sh" dir="${basedir}/tests">
       
    98                         <env key="ANT_LIB_HOME" path="${helium.antlib.root.dir}"/>
       
    99                         <arg line="unittest" />
       
   100                     </exec>
       
   101                 </then>
       
   102             </if>
       
   103         </sequential>
       
   104     </macrodef>
       
   105     
       
   106     
       
   107     <path id="emma.classpath">
       
   108         <fileset dir="${helium.antlib.root.dir}\antlibs">
       
   109             <include name="**/*.jar" />
       
   110         </fileset>
       
   111     </path>
       
   112     <taskdef classpathref="emma.classpath" resource="emma_ant.properties" />
       
   113  
       
   114     
       
   115     <macrodef name="junitModule">
       
   116         <attribute name="name" />
       
   117         <attribute name="dir" default="${helium.antlib.root.dir}" />
       
   118         <sequential>
       
   119             <if>
       
   120                 <available type="dir" file="${basedir}/tests/src"/>
       
   121                 <then>
       
   122                     <echo>JUnit test module @{name}</echo>
       
   123                     <delete dir="${build.temp.dir}/@{name}/junit_classes"/>
       
   124                     <mkdir dir="${build.temp.dir}/@{name}/junit_classes" />
       
   125                     <javac srcdir="${basedir}/tests/src" destdir="${build.temp.dir}/@{name}/junit_classes" debug="true" source="1.5" target="1.5">
       
   126                         <classpath refid="helium.antlib.classpath" />
       
   127                         <classpath refid="helium.@{name}.classpath" />
       
   128                         <include name="**/*.java" />
       
   129                     </javac>
       
   130                     
       
   131                     <path id="build.classpath">
       
   132                         <pathelement location="${build.temp.dir}/@{name}/classes" />
       
   133                         <pathelement location="${build.temp.dir}/@{name}/junit_classes" />
       
   134                     </path>
       
   135                     
       
   136                     <emma enabled="true">
       
   137                         <instr instrpathref="build.classpath"  
       
   138                         destdir="${build.temp.dir}/@{name}/emma/instrumented"  
       
   139                         metadatafile="${build.temp.dir}/@{name}/metadata.emma"
       
   140                         merge="true">
       
   141                             <filter excludes="org.apache.log4j.*" />
       
   142                         </instr>
       
   143                     </emma>
       
   144                     
       
   145                     <junit fork="yes" printsummary="yes" haltonfailure="yes" showoutput="yes">
       
   146                         <formatter type="brief" usefile="false"/>
       
   147                         <jvmarg value="-Demma.coverage.out.file=${build.temp.dir}/@{name}/coverage.emma" />
       
   148                         <jvmarg value="-Demma.coverage.out.merge=false" />
       
   149                         <jvmarg value="-Dtestdir=${basedir}" />
       
   150                         <classpath refid="helium.antlib.classpath" />
       
   151                         <classpath refid="helium.@{name}.classpath" />
       
   152                         <classpath>
       
   153                             <pathelement path="${build.temp.dir}/@{name}/emma/instrumented"/>
       
   154                             <pathelement path="${helium.antlib.root.dir}/antlibs/*.jar"/>
       
   155                         </classpath>
       
   156                         <batchtest fork="yes" todir="${build.temp.dir}/@{name}/junit_test">
       
   157                             <fileset dir="${basedir}/tests/src">
       
   158                                 <include name="**/*Test*.java"/>
       
   159                             </fileset>
       
   160                         </batchtest>
       
   161                     </junit>
       
   162                     
       
   163                     <emma enabled="true" >
       
   164                         <report>
       
   165                             <infileset dir="${build.temp.dir}/@{name}" includes="*.emma" />
       
   166                             <txt outfile="${build.temp.dir}/@{name}/coverage.txt" />
       
   167                             <html outfile="${build.temp.dir}/@{name}/coverage.html" />
       
   168                         </report>
       
   169                     </emma>
       
   170                     <loadfile property="message" srcFile="${build.temp.dir}/@{name}/coverage.txt"/>
       
   171                     <echo message="${message}"/>
       
   172                 </then>
       
   173             </if>
       
   174         </sequential>
       
   175     </macrodef>
       
   176     
       
   177     
       
   178     <target name="compile">
       
   179         <echo>Compiling ${ant.project.name}</echo>
       
   180         <compileModule name="${name}"/>
       
   181     </target>
       
   182     
       
   183     
       
   184     <target name="jar">
       
   185         <echo>Creating jar for ${ant.project.name}</echo>
       
   186         <jarModule name="${name}"/>
       
   187     </target>
       
   188     
       
   189     
       
   190     <target name="build" depends="compile,jar">
       
   191         <echo>${ant.project.name} is built.</echo>
       
   192     </target>
       
   193     
       
   194     
       
   195     <target name="clean">
       
   196         <echo>Cleaning ${ant.project.name}</echo>
       
   197         <delete dir="${build.temp.dir}/${name}/classes"/>
       
   198         <delete file="${bin.dir}/helium-${name}.jar"/>
       
   199     </target>
       
   200     
       
   201     
       
   202     <target name="junit">
       
   203         <junitModule name="${name}"/>
       
   204     </target>
       
   205     
       
   206     
       
   207     <target name="unittest">
       
   208         <testModule name="${name}"/>
       
   209     </target>
       
   210     
       
   211     
       
   212     <target name="test" depends="junit,unittest">
       
   213         <echo>${ant.project.name} tested.</echo>
       
   214     </target>
       
   215 </project>
       
   216 
       
   217 
       
   218