buildframework/helium/external/helium-antlib/macros.ant.xml
changeset 179 d8ac696cc51f
parent 1 be27ed110b50
equal deleted inserted replaced
1:be27ed110b50 179:d8ac696cc51f
    22 -->
    22 -->
    23 <project name="build-macros" xmlns:au="org.apache.ant.antunit">
    23 <project name="build-macros" xmlns:au="org.apache.ant.antunit">
    24     <description>Helium Antlib build macro.</description>
    24     <description>Helium Antlib build macro.</description>
    25     
    25     
    26     <dirname property="helium.antlib.root.dir" file="${ant.file.build-macros}" />
    26     <dirname property="helium.antlib.root.dir" file="${ant.file.build-macros}" />
    27     <property name="build.temp.dir" location="${basedir}/../build" />
    27     <property name="build.temp.dir" location="${helium.antlib.root.dir}/../build" />
    28     <property name="bin.dir" location="${basedir}/../bin" />
    28     <property name="bin.dir" location="${basedir}/../bin" />
    29 
    29 
    30     <path id="helium.antlib.classpath">
    30     <path id="helium.antlib.classpath">
    31         <fileset dir="${helium.antlib.root.dir}/lib" includes="*.jar" />
    31         <fileset dir="${helium.antlib.root.dir}/lib" includes="*.jar" />
    32         <fileset dir="${helium.antlib.root.dir}/antlibs" includes="*.jar" />
    32         <fileset dir="${helium.antlib.root.dir}/antlibs" includes="*.jar" />
    69             <mkdir dir="@{bindir}" />
    69             <mkdir dir="@{bindir}" />
    70             <jar destfile="@{bindir}/helium-@{name}.jar">
    70             <jar destfile="@{bindir}/helium-@{name}.jar">
    71                 <fileset dir="${build.temp.dir}/@{name}/classes" />
    71                 <fileset dir="${build.temp.dir}/@{name}/classes" />
    72                 <fileset dir="${basedir}/src" includes="**/*.xml" />
    72                 <fileset dir="${basedir}/src" includes="**/*.xml" />
    73                 <fileset dir="${basedir}/src" includes="**/*.*ftl" />
    73                 <fileset dir="${basedir}/src" includes="**/*.*ftl" />
    74 
    74                 <fileset dir="${basedir}/src" includes="**/*.vm" />
       
    75                 
    75                 <manifest>
    76                 <manifest>
    76                     <section name="common">
    77                     <section name="common">
    77                         <attribute name="Implementation-Title" value="@{name}" />
    78                         <attribute name="Implementation-Title" value="@{name}" />
    78                         <attribute name="Implementation-Vendor" value="Nokia" />
    79                         <attribute name="Implementation-Vendor" value="Nokia" />
    79                     </section>
    80                     </section>
    84     
    85     
    85 
    86 
    86     <macrodef name="testModule">
    87     <macrodef name="testModule">
    87         <attribute name="name" />
    88         <attribute name="name" />
    88         <attribute name="dir" default="${helium.antlib.root.dir}" />
    89         <attribute name="dir" default="${helium.antlib.root.dir}" />
    89         <sequential>
    90         <attribute name="bindir" default="${bin.dir}" />
       
    91         <sequential>
       
    92             <mkdir dir="${build.temp.dir}" />
    90             <if>
    93             <if>
    91                 <available type="dir" file="${basedir}/tests"/>
    94                 <available type="dir" file="${basedir}/tests"/>
    92                 <then>
    95                 <then>
    93                     <exec osfamily="windows" executable="cmd" dir="${basedir}/tests">
    96                     <trycatch>
    94                         <env key="ANT_LIB_HOME" path="${helium.antlib.root.dir}"/>
    97                         <try>
    95                         <arg line="/c build.bat unittest" />
    98                             <!-- Temporarly replacing the jar file
    96                     </exec>
    99                                  with an instrumented one to do the 
    97                     <exec osfamily="unix" executable="./bld.sh" dir="${basedir}/tests">
   100                                  actual coverage measurment
    98                         <env key="ANT_LIB_HOME" path="${helium.antlib.root.dir}"/>
   101                              -->
    99                         <arg line="unittest" />
   102                             <mkdir dir="${build.temp.dir}/@{name}/backup" />
   100                     </exec>
   103                             <delete>
       
   104                                 <fileset dir="${build.temp.dir}" includes="@{name}/**/*_antunit.emma" />
       
   105                             </delete>
       
   106                             <copy file="@{bindir}/helium-@{name}.jar" todir="${build.temp.dir}/@{name}/backup/" />
       
   107                             <emma enabled="true">
       
   108                                 <instr destdir="@{bindir}/" metadatafile="${build.temp.dir}/@{name}/metadata_antunit.emma" merge="true" mode="overwrite">
       
   109                                     <instrpath>
       
   110                                         <fileset dir="@{bindir}" includes="helium-@{name}.jar" />
       
   111                                     </instrpath>
       
   112                                 </instr>
       
   113                             </emma>
       
   114                             <exec osfamily="windows" executable="cmd" dir="${basedir}/tests">
       
   115                                 <env key="ANT_LIB_HOME" path="${helium.antlib.root.dir}" />
       
   116                                 <arg line="/c build.bat unittest" />
       
   117                             </exec>
       
   118                             <exec osfamily="unix" executable="./bld.sh" dir="${basedir}/tests">
       
   119                                 <env key="ANT_LIB_HOME" path="${helium.antlib.root.dir}" />
       
   120                                 <arg line="unittest" />
       
   121                             </exec>
       
   122                             <move todir="${build.temp.dir}/@{name}">
       
   123                                 <fileset dir="${basedir}/tests" includes="**/coverage.ec" />
       
   124                                 <chainedmapper>
       
   125                                     <filtermapper>
       
   126                                         <replacestring from="/" to="_" />
       
   127                                     </filtermapper>
       
   128                                     <regexpmapper from="^(.*)\.ec$$" to="\1_antunit.emma" />
       
   129                                 </chainedmapper>
       
   130                             </move>
       
   131                             <emma enabled="true">
       
   132                                 <report>
       
   133                                     <infileset dir="${build.temp.dir}/@{name}/" includes="*_antunit.emma" />
       
   134                                     <txt outfile="${build.temp.dir}/@{name}/coverage_antunit.txt" />
       
   135                                     <html outfile="${build.temp.dir}/@{name}/coverage_antunit.html" />
       
   136                                     <xml outfile="${build.temp.dir}/@{name}/coverage_antunit.xml" />
       
   137                                 </report>
       
   138                             </emma>
       
   139                             <if>
       
   140                                 <available file="${build.temp.dir}/@{name}/coverage_antunit.txt" />
       
   141                                 <then>
       
   142                                     <loadfile property="message" srcFile="${build.temp.dir}/@{name}/coverage_antunit.txt" />
       
   143                                     <echo message="${message}" />
       
   144                                 </then>
       
   145                             </if>
       
   146                         </try>
       
   147                         <finally>
       
   148                             <copy file="${build.temp.dir}/@{name}/backup/helium-@{name}.jar" todir="@{bindir}" overwrite="true" />
       
   149                         </finally>
       
   150                     </trycatch>
   101                 </then>
   151                 </then>
   102             </if>
   152             </if>
   103         </sequential>
   153         </sequential>
   104     </macrodef>
   154     </macrodef>
   105     
   155     
   113  
   163  
   114     
   164     
   115     <macrodef name="junitModule">
   165     <macrodef name="junitModule">
   116         <attribute name="name" />
   166         <attribute name="name" />
   117         <attribute name="dir" default="${helium.antlib.root.dir}" />
   167         <attribute name="dir" default="${helium.antlib.root.dir}" />
   118         <sequential>
   168         <attribute name="bindir" default="${bin.dir}" />
       
   169         <sequential>
       
   170             <mkdir dir="${build.temp.dir}" />
   119             <if>
   171             <if>
   120                 <available type="dir" file="${basedir}/tests/src"/>
   172                 <available type="dir" file="${basedir}/tests/src"/>
   121                 <then>
   173                 <then>
   122                     <echo>JUnit test module @{name}</echo>
   174                     <echo>JUnit test module @{name}</echo>
   123                     <delete dir="${build.temp.dir}/@{name}/junit_classes"/>
   175                     <delete dir="${build.temp.dir}/@{name}/junit_classes"/>
       
   176                     <delete>
       
   177                         <fileset dir="${build.temp.dir}" includes="@{name}/**/*_junit.emma" />
       
   178                     </delete>
   124                     <mkdir dir="${build.temp.dir}/@{name}/junit_classes" />
   179                     <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">
   180                     <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" />
   181                         <classpath refid="helium.antlib.classpath" />
   127                         <classpath refid="helium.@{name}.classpath" />
   182                         <classpath refid="helium.@{name}.classpath" />
       
   183                         <classpath>
       
   184                             <fileset dir="@{bindir}" includes="*-@{name}.jar" />
       
   185                         </classpath>
   128                         <include name="**/*.java" />
   186                         <include name="**/*.java" />
   129                     </javac>
   187                     </javac>
   130                     
   188             
   131                     <path id="build.classpath">
   189                     <copy file="@{bindir}/helium-@{name}.jar" todir="${build.temp.dir}/@{name}/" overwrite="true"/>
   132                         <pathelement location="${build.temp.dir}/@{name}/classes" />
       
   133                         <pathelement location="${build.temp.dir}/@{name}/junit_classes" />
       
   134                     </path>
       
   135                     
       
   136                     <emma enabled="true">
   190                     <emma enabled="true">
   137                         <instr instrpathref="build.classpath"  
   191                         <instr destdir="${build.temp.dir}/@{name}/" metadatafile="${build.temp.dir}/@{name}/metadata_junit.emma" merge="true" mode="overwrite">
   138                         destdir="${build.temp.dir}/@{name}/emma/instrumented"  
   192                             <instrpath>
   139                         metadatafile="${build.temp.dir}/@{name}/metadata.emma"
   193                                 <fileset dir="${build.temp.dir}/@{name}/" includes="helium-@{name}.jar" />
   140                         merge="true">
   194                             </instrpath>
   141                             <filter excludes="org.apache.log4j.*" />
       
   142                         </instr>
   195                         </instr>
   143                     </emma>
   196                     </emma>
   144                     
   197                     
       
   198                     <delete file="${build.temp.dir}/@{name}/coverage.emma" failonerror="false" />
   145                     <junit fork="yes" printsummary="yes" haltonfailure="yes" showoutput="yes">
   199                     <junit fork="yes" printsummary="yes" haltonfailure="yes" showoutput="yes">
   146                         <formatter type="brief" usefile="false"/>
   200                         <formatter type="brief" usefile="false"/>
   147                         <jvmarg value="-Demma.coverage.out.file=${build.temp.dir}/@{name}/coverage.emma" />
   201                         <jvmarg value="-Demma.coverage.out.file=${build.temp.dir}/@{name}/coverage_junit.emma" />
   148                         <jvmarg value="-Demma.coverage.out.merge=false" />
   202                         <jvmarg value="-Demma.coverage.out.merge=true" />
   149                         <jvmarg value="-Dtestdir=${basedir}" />
   203                         <jvmarg value="-Dtestdir=${basedir}" />
       
   204                         <classpath>
       
   205                             <pathelement path="${build.temp.dir}/@{name}/helium-@{name}.jar"/>
       
   206                             <pathelement path="${helium.antlib.root.dir}/antlibs/*.jar"/>
       
   207                             <pathelement path="${build.temp.dir}/@{name}/junit_classes" />
       
   208                         </classpath>
   150                         <classpath refid="helium.antlib.classpath" />
   209                         <classpath refid="helium.antlib.classpath" />
   151                         <classpath refid="helium.@{name}.classpath" />
   210                         <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">
   211                         <batchtest fork="yes" todir="${build.temp.dir}/@{name}/junit_test">
   157                             <fileset dir="${basedir}/tests/src">
   212                             <fileset dir="${basedir}/tests/src">
   158                                 <include name="**/*Test*.java"/>
   213                                 <include name="**/*Test*.java"/>
   159                             </fileset>
   214                             </fileset>
   160                         </batchtest>
   215                         </batchtest>
   161                     </junit>
   216                     </junit>
       
   217                     <delete file="${build.temp.dir}/@{name}/helium-@{name}.jar" failonerror="false" />
   162                     
   218                     
   163                     <emma enabled="true" >
   219                     <emma enabled="true" >
   164                         <report>
   220                         <report>
   165                             <infileset dir="${build.temp.dir}/@{name}" includes="*.emma" />
   221                             <infileset dir="${build.temp.dir}/@{name}" includes="*_junit.emma" />
   166                             <txt outfile="${build.temp.dir}/@{name}/coverage.txt" />
   222                             <txt outfile="${build.temp.dir}/@{name}/coverage.txt" />
   167                             <html outfile="${build.temp.dir}/@{name}/coverage.html" />
   223                             <html outfile="${build.temp.dir}/@{name}/coverage.html" />
       
   224                             <xml outfile="${build.temp.dir}/@{name}/coverage.xml" />
   168                         </report>
   225                         </report>
   169                     </emma>
   226                     </emma>
   170                     <loadfile property="message" srcFile="${build.temp.dir}/@{name}/coverage.txt"/>
   227                     <if>
   171                     <echo message="${message}"/>
   228                         <available file="${build.temp.dir}/@{name}/coverage.txt" />
       
   229                         <then>
       
   230                             <loadfile property="message" srcFile="${build.temp.dir}/@{name}/coverage.txt"/>
       
   231                             <echo message="${message}"/>
       
   232                         </then>
       
   233                     </if>
   172                 </then>
   234                 </then>
   173             </if>
   235             </if>
   174         </sequential>
   236         </sequential>
   175     </macrodef>
   237     </macrodef>
   176     
   238