1 <?xml version="1.0" encoding="UTF-8"?>
   2 
   3 <!--
   4   Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   5   DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6 
   7   This code is free software; you can redistribute it and/or modify it
   8   under the terms of the GNU General Public License version 2 only, as
   9   published by the Free Software Foundation.  Oracle designates this
  10   particular file as subject to the "Classpath" exception as provided
  11   by Oracle in the LICENSE file that accompanied this code.
  12 
  13   This code is distributed in the hope that it will be useful, but WITHOUT
  14   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16   version 2 for more details (a copy is included in the LICENSE file that
  17   accompanied this code).
  18 
  19   You should have received a copy of the GNU General Public License version
  20   2 along with this work; if not, write to the Free Software Foundation,
  21   Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  22 
  23   Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  24   or visit www.oracle.com if you need additional information or have any
  25   questions.
  26 -->
  27 
  28 <project name="JCov" default="build" basedir=".">
  29 
  30     <property file="release.properties"/>
  31     <property file="build.properties"/>
  32     <import file="check-dependecies.xml"/>
  33 
  34     <!-- Build area -->
  35     <property name="build.dir" location="${result.dir}/jcov_${build.version}"/>
  36     <property name="jcov.classpath" value="${asm.jar}:${asm.util.jar}:${asm.tree.jar}:${java.home}/lib/tools.jar"/>
  37 
  38     <!-- Temp dir is for files which do not appear in release directory -->
  39     <property name="tmp.dir" location="${result.dir}/temp"/>
  40 
  41     <property name="jcov.classes" location="${tmp.dir}/jcov_classes"/>
  42     <property name="jcov.src.update" location="${tmp.dir}/jcov_src_update"/>
  43 
  44     <property name="jcov.filesaver.classes" location="${tmp.dir}/jcov_filesaver_classes"/>
  45     <property name="jcov.filesaver.src" location="${tmp.dir}/jcov_filesaver_src"/>
  46 
  47     <property name="jcov.networksaver.classes" location="${tmp.dir}/jcov_network_classes"/>
  48     <property name="jcov.networksaver.src" location="${tmp.dir}/jcov_network_src"/>
  49 
  50     <property name="jcov.jtobserver.classes" location="${tmp.dir}/jcov_jtobserver_classes"/>
  51 
  52     <patternset id="jcov.files">
  53         <include name="com/sun/tdk/jcov/**"/>
  54         <include name="resources/**"/>
  55     </patternset>
  56 
  57     <patternset id="jcov.file.saver.files">
  58         <include name="com/sun/tdk/jcov/runtime/Collect.*"/>
  59         <include name="com/sun/tdk/jcov/runtime/CollectDetect.*"/>
  60         <include name="com/sun/tdk/jcov/runtime/JCovSaver.*"/>
  61         <include name="com/sun/tdk/jcov/runtime/SaverDecorator.*"/>
  62         <include name="com/sun/tdk/jcov/runtime/PropertyFinder.*"/>
  63         <include name="com/sun/tdk/jcov/util/MapHelper.*"/>
  64         <include name="com/sun/tdk/jcov/util/RuntimeUtils.*"/>
  65         <include name="com/sun/tdk/jcov/runtime/TemplateFileSaver*"/>
  66         <include name="com/sun/tdk/jcov/util/MapHelper.*"/>
  67         <include name="com/sun/tdk/jcov/constants/MiscConstants*"/>
  68     </patternset>
  69 
  70     <patternset id="jcov.network.saver.files">
  71         <include name="com/sun/tdk/jcov/runtime/Collect.*"/>
  72         <include name="com/sun/tdk/jcov/runtime/CollectDetect.*"/>
  73         <include name="com/sun/tdk/jcov/runtime/PropertyFinder.*"/>
  74         <include name="com/sun/tdk/jcov/runtime/JCovSocketSaver.*"/>
  75         <include name="com/sun/tdk/jcov/runtime/JCovSESocketSaver.*"/>
  76         <include name="com/sun/tdk/jcov/runtime/JCovSaver.*"/>
  77         <include name="com/sun/tdk/jcov/runtime/NetworkSatelliteDecorator.*"/>
  78         <include name="com/sun/tdk/jcov/runtime/SaverDecorator.*"/>
  79     </patternset>
  80 
  81     <fileset dir="${src.dir}" id="jcov.resources.files">
  82         <include name="com/sun/tdk/jcov/report/html/resources/**"/>
  83         <include name="com/sun/tdk/jcov/logging.properties"/>
  84         <exclude name="**/*.java"/>
  85     </fileset>
  86 
  87     <patternset id="asm.files">
  88         <include name="org/objectweb/asm/**"/>
  89     </patternset>
  90 
  91     <target name="clean" description="clean build data">
  92 
  93         <delete dir="${build.dir}"/>
  94         <delete dir="${tmp.dir}"/>
  95 
  96     </target>
  97 
  98     <target name="prepare" depends="clean, verify-dependencies" description="checks dependencies">
  99 
 100         <condition property="javatest.present">
 101             <and>
 102                 <isset property="javatestjar"/>
 103                 <not>
 104                     <equals arg1="${javatestjar}" arg2=""/>
 105                 </not>
 106             </and>
 107         </condition>
 108 
 109         <mkdir dir="${build.dir}"/>
 110         <mkdir dir="${tmp.dir}"/>
 111         <mkdir dir="${jcov.src.update}"/>
 112         <mkdir dir="${jcov.classes}"/>
 113 
 114     </target>
 115 
 116     <target name="build-date" description="adds bild and date information">
 117         <tstamp>
 118             <format property="date" pattern="dd MMMM yyyy" locale="en"/>
 119         </tstamp>
 120         <mkdir dir="${jcov.src.update}/com/sun/tdk/jcov/tools"/>
 121         <echo file="${jcov.src.update}/com/sun/tdk/jcov/tools/JcovVersion.java">
 122             /*
 123             * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
 124             * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 125             *
 126             * This code is free software; you can redistribute it and/or modify it
 127             * under the terms of the GNU General Public License version 2 only, as
 128             * published by the Free Software Foundation.  Oracle designates this
 129             * particular file as subject to the "Classpath" exception as provided
 130             * by Oracle in the LICENSE file that accompanied this code.
 131             *
 132             * This code is distributed in the hope that it will be useful, but WITHOUT
 133             * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 134             * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 135             * version 2 for more details (a copy is included in the LICENSE file that
 136             * accompanied this code).
 137             *
 138             * You should have received a copy of the GNU General Public License version
 139             * 2 along with this work; if not, write to the Free Software Foundation,
 140             * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 141             *
 142             * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 143             * or visit www.oracle.com if you need additional information or have any
 144             * questions.
 145             */
 146 
 147             package com.sun.tdk.jcov.tools;
 148 
 149             public class JcovVersion{
 150             public static final String jcovVersion = "${build.version}";
 151             public static final String jcovMilestone = "${build.milestone}";
 152             public static final String jcovBuildNumber = "${build.number}";
 153             public static final String jcovBuildDate = "${date}";
 154             public static String getJcovVersion() {
 155                 return String.format("%s%s-%s built: %s", jcovVersion, jcovMilestone, jcovBuildNumber, jcovBuildDate);
 156               }
 157             }
 158         </echo>
 159 
 160     </target>
 161 
 162     <target name="compile"  depends="prepare, build-date"
 163             description="compile main tools">
 164 
 165         <javac includeantruntime="false" encoding="iso-8859-1" debug="true" target="1.7" source="1.7"
 166                srcdir="${jcov.src.update}"
 167                destdir="${jcov.classes}"
 168                classpath="${jcov.classpath}">
 169         </javac>
 170 
 171         <javac includeantruntime="true" encoding="iso-8859-1" debug="true" target="1.7" source="1.7"
 172                srcdir="${src.dir}"
 173                destdir="${jcov.classes}"
 174                classpath="${jcov.classpath}">
 175             <patternset refid="jcov.files"/>
 176         </javac>
 177 
 178         <copy todir="${jcov.classes}">
 179             <fileset refid="jcov.resources.files"/>
 180         </copy>
 181     </target>
 182 
 183     <patternset id="jcov.services">
 184         <include name="META-INF/services/**"/>
 185     </patternset>
 186 
 187     <target name="build-jcov" depends="compile" description="build jcov jar">
 188         <unjar src="${asm.jar}" dest="${jcov.classes}"/>
 189         <unjar src="${asm.tree.jar}" dest="${jcov.classes}"/>
 190         <unjar src="${asm.util.jar}" dest="${jcov.classes}"/>
 191 
 192         <mkdir dir="${jcov.classes}/META-INF"/>
 193         <mkdir dir="${jcov.classes}/META-INF/services"/>
 194         <echo file="${jcov.classes}/META-INF/services/com.sun.tdk.jcov.report.ancfilters.DefaultAncFilter"
 195               append="false">
 196             com.sun.tdk.jcov.report.ancfilters.ToStringANCFilter
 197             com.sun.tdk.jcov.report.ancfilters.DeprecatedANCFilter
 198             com.sun.tdk.jcov.report.ancfilters.EmptyANCFilter
 199             com.sun.tdk.jcov.report.ancfilters.CatchANCFilter
 200             com.sun.tdk.jcov.report.ancfilters.ThrowANCFilter
 201             com.sun.tdk.jcov.report.ancfilters.SyntheticANCFilter
 202             com.sun.tdk.jcov.report.ancfilters.GetterANCFilter
 203             com.sun.tdk.jcov.report.ancfilters.SetterANCFilter
 204         </echo>
 205 
 206         <jar destfile="${build.dir}/jcov.jar" basedir="${jcov.classes}" index="false">
 207             <manifest>
 208                 <attribute name="Built-By"   value="${user.name}"/>
 209                 <attribute name="Premain-Class" value="com.sun.tdk.jcov.Agent"/>
 210                 <attribute name="Boot-Class-Path" value="jcov.jar"/>
 211                 <attribute name="Main-Class" value="com.sun.tdk.jcov.Helper"/>
 212                 <attribute name="Can-Retransform-Classes" value="true"/>
 213                 <attribute name="Can-Set-Native-Method-Prefix" value="true" />
 214             </manifest>
 215 
 216             <patternset refid="jcov.files"/>
 217             <patternset refid="asm.files"/>
 218             <patternset refid="jcov.services"/>
 219         </jar>
 220 
 221     </target>
 222 
 223     <target name="build-file.saver" depends="prepare" description="build file saver jar">
 224 
 225         <mkdir dir="${jcov.filesaver.classes}"/>
 226         <mkdir dir="${jcov.filesaver.src}"/>
 227 
 228         <copy todir="${jcov.filesaver.src}">
 229             <fileset dir="${src.dir}">
 230                 <patternset refid="jcov.file.saver.files"/>
 231             </fileset>
 232             <fileset dir="${jcov.src.update}">
 233             </fileset>
 234             <filterchain>
 235                 <tokenfilter>
 236                     <replaceregex pattern="\/\*@" replace="@"/>
 237                     <replaceregex pattern="@\*\/" replace="@"/>
 238                 </tokenfilter>
 239                 <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
 240                     <param type="propertiesfile" value="filesaver.replace.properties"/>
 241                 </filterreader>
 242             </filterchain>
 243         </copy>
 244         <javac includeantruntime="true" encoding="iso-8859-1" debug="true" target="1.7" source="1.7"
 245                srcdir="${jcov.filesaver.src}"
 246                sourcepath=""
 247                classpath="${jcov.filesaver.classes}"
 248                destdir="${jcov.filesaver.classes}">
 249         </javac>
 250         <jar destfile="${build.dir}/jcov_file_saver.jar"
 251              basedir="${jcov.filesaver.classes}"
 252              index="false">
 253             <manifest>
 254                 <attribute name="Built-By" value="${user.name}"/>
 255             </manifest>
 256         </jar>
 257     </target>
 258 
 259     <target name="build-network.saver" depends="prepare" description="build network saver jar">
 260 
 261         <mkdir dir="${jcov.networksaver.classes}"/>
 262         <mkdir dir="${jcov.networksaver.src}"/>
 263 
 264         <copy todir="${jcov.networksaver.src}">
 265             <fileset dir="${src.dir}">
 266                 <patternset refid="jcov.network.saver.files"/>
 267             </fileset>
 268             <filterchain>
 269                 <tokenfilter>
 270                     <replaceregex pattern="\/\*@" replace="@"/>
 271                     <replaceregex pattern="@\*\/" replace="@"/>
 272                 </tokenfilter>
 273                 <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
 274                     <param type="propertiesfile" value="networksaver.replace.properties"/>
 275                 </filterreader>
 276             </filterchain>
 277         </copy>
 278         <javac includeantruntime="true" encoding="iso-8859-1" debug="true" target="1.7" source="1.7"
 279                srcdir="${jcov.networksaver.src}"
 280                sourcepath=""
 281                classpath="${jcov.networksaver.classes}"
 282                destdir="${jcov.networksaver.classes}">
 283         </javac>
 284         <jar destfile="${build.dir}/jcov_network_saver.jar"
 285              basedir="${jcov.networksaver.classes}"
 286              index="false">
 287             <manifest>
 288                 <attribute name="Built-By" value="${user.name}"/>
 289             </manifest>
 290         </jar>
 291     </target>
 292 
 293     <target name="build-jt.observer" depends="prepare" if ="javatest.present" description="build jtobserver jar">
 294         <mkdir dir="${jcov.jtobserver.classes}"/>
 295         <javac includeantruntime="false" encoding="iso-8859-1" debug="true" target="1.7" source="1.7"
 296                srcdir="${src.dir}"
 297                sourcepath=""
 298                destdir="${jcov.jtobserver.classes}" classpath="${javatestjar}">
 299             <include name="jcov/*"/>
 300         </javac>
 301         <jar destfile ="${build.dir}/jtobserver.jar" basedir="${jcov.jtobserver.classes}" index="false"/>
 302     </target>
 303 
 304     <target name="build"
 305             depends="build-jcov, build-file.saver, build-network.saver, build-jt.observer"
 306             description="Creates the build-distribution.">
 307     </target>
 308 
 309 </project>