Home | History | Annotate | Download | only in buildfiles
      1 <?xml version="1.0" encoding="utf-8"?>
      2 <project name="lib" basedir=".">
      3 
      4   <taskdef resource="net/sf/antcontrib/antlib.xml"/>
      5 
      6   <!--Location of DITA Open Toolkit-->
      7   <property name="dita.dir" value="${basedir}/../../../tools/ditaot"/>
      8   <!--Location of DITA source files to build-->
      9   <property name="src-dir" value="${basedir}/../../../src"/>
     10   <!--Location of temp folder-->
     11   <property name="temp-dir" value="${basedir}/temp"/>
     12   <!--Location of logs folder-->
     13   <property name="log-dir" value="${basedir}/logs"/>
     14   <!--Path of file containing context extension points for context-sensitive help-->
     15   <property name="context-file" value="${basedir}/context_extension_points.xml"/>
     16   <!--If present, load file containing Eclipse enablement elements for Windows-only content.-->
     17   <available file="enable-win32.xml" property="enablement-present"/>
     18   <if>
     19     <isset property="enablement-present"/>
     20     <then>
     21       <loadfile property="enablement-win32" srcfile="enable-win32.xml"/>
     22     </then>
     23   </if>
     24 
     25   <!--  References ANT extension that provides Perl 5 compatible regex functionality.-->
     26   <property name="ant.regexp.regexpimpl" value="org.apache.tools.ant.util.regexp.JakartaOroRegexp"/>
     27 
     28   <!--Import DITA OT build file-->
     29   <import file="${dita.dir}/build.xml"/>
     30 
     31   <target name="clean" description="Delete all generated files (out, temp, and logs folders)">
     32     <delete dir="${out-projdir}" quiet="yes"/>
     33     <delete dir="${log-dir}" quiet="yes"/>
     34     <delete dir="${temp-dir}" quiet="yes"/>
     35     <delete file="${basedir}/ditaot_batch.log"/>
     36   </target>
     37 
     38   <macrodef name="build-topics-plugin" description="Build a DevEd Eclipse help plug-in">
     39     <attribute name="map" default="NOT_SET"/>
     40     <attribute name="ditaval" default="NOT_SET"/>
     41     <attribute name="hdr" default="NOT_SET"/>
     42     <attribute name="provider" default="Motorola Mobility, Inc."/>
     43     <element name="build-callers-tasks" implicit="yes" optional="yes"/>
     44     <sequential>
     45       <echo/>
     46       <echo>=============================================================================</echo>
     47       <echo>START build-topics-plugin for @{map}</echo>
     48       <echo>Ditaval file: "@{ditaval}"</echo>
     49       <property name="@{map}-path" value="${src-dir}/@{map}"/>
     50       <!-- Reads ditamap into ANT XML properties so that build script can use same map ID as plug-in ID everywhere. -->
     51       <xmlproperty file="${@{map}-path}" prefix="@{map}"/>
     52       <property name="@{map}-plugin-id" value="${@{map}.map(id)}"/>
     53       <echo>Plug-in ID: ${@{map}-plugin-id}</echo>
     54       <property name="@{map}-plugin-out-dir"
     55         value="${out-basedir}/${@{map}-plugin-id}_${plugin-version}"/>
     56       <property name="@{map}-plugin-temp-dir"
     57         value="${temp-dir}/${@{map}-plugin-id}_${plugin-version}"/>
     58       <!-- Get copyright info from map file -->
     59       <property name="@{map}-copyryear" value="${@{map}.map.topicmeta.copyright.copyryear(year)}"/>
     60       <property name="@{map}-copyrholder" value="${@{map}.map.topicmeta.copyright.copyrholder}"/>
     61       <echo>Copyright date: ${@{map}-copyryear}</echo>
     62       <echo>Copyright holder: ${@{map}-copyrholder}</echo>
     63       <!--Delete output folder before building so no unnecessary files from previous build are left.-->
     64       <delete dir="${@{map}-plugin-out-dir}" quiet="yes"/>
     65 
     66       <!-- Call DITA-OT build script-->
     67       <ant antfile="${dita.dir}/build.xml" target="init" description="Call DITA OT build script">
     68         <property name="transtype" value="eclipsehelp"/>
     69         <property name="args.input" value="${@{map}-path}"/>
     70         <property name="dita.input.valfile" value="@{ditaval}"/>
     71         <property name="args.hdr" value="@{hdr}"/>
     72         <property name="output.dir" value="${@{map}-plugin-out-dir}"/>
     73         <property name="dita.temp.dir" value="${@{map}-plugin-temp-dir}"/>
     74         <property name="args.logdir" value="${log-dir}"/>
     75         <!-- Sets "Bundle-Version" in meta-mf/manifest.mf, the version of this help plug-in. -->
     76         <property name="args.eclipse.version" value="${plugin-version}"/>
     77         <property name="args.eclipse.provider" value="@{provider}"/>
     78         <property name="args.eclipsehelp.toc" value="${toc-filenoext}"/>
     79       </ant>
     80 
     81       <!--Change filename of TOC file from ditamapname.xml to specified.-->
     82       <basename property="@{map}-filenoext" file="@{map}" suffix=".ditamap"/>
     83       <move file="${@{map}-plugin-out-dir}/${@{map}-filenoext}.xml"
     84         tofile="${@{map}-plugin-out-dir}/${toc-filenoext}.xml"/>
     85 
     86       <deleteflagimages output-dir="${@{map}-plugin-out-dir}"/>
     87       <replacecss output-dir="${@{map}-plugin-out-dir}"/>
     88 
     89       <!--Replace special anchors in TOC with Eclipse enablement elements-->
     90       <!--Set anchor id="eclipse-enable-win32onlyXXX" for topics that should appear in TOC only in Windows.-->
     91       <!--XXX can be anything (required only to make anchor id unique in ditamap file.-->
     92       <if>
     93         <isset property="enablement-present"/>
     94         <then>
     95           <replaceregexp file="${@{map}-plugin-out-dir}/${toc-filenoext}.xml"
     96             match="\s*?&lt;anchor\s+id\s*?=\s*?&quot;eclipse-enable-win32only.*?&quot;\s*?/&gt;"
     97             replace="${enablement-win32}" flags="gi"/>
     98         </then>
     99       </if>
    100 
    101       <!--Move debugging files to temp folder.-->
    102       <!--<move file="${@{map}-plugin-out-dir}/dita.list" todir="${@{map}-plugin-temp-dir}"/>
    103         <move file="${@{map}-plugin-out-dir}/dita.xml.properties" todir="${@{map}-plugin-temp-dir}"/>-->
    104 
    105       <!--Perform caller's implicit tasks here-->
    106       <build-callers-tasks/>
    107 
    108       <echo>END build-topics-plugin for @{map}</echo>
    109     </sequential>
    110   </macrodef>
    111 
    112 
    113   <macrodef name="build-cshelp" description="Build cshelp for a DevEd Eclipse help plug-in">
    114     <attribute name="cshelp-topic" default="NOT_SET"/>
    115     <attribute name="ditaval" default="NOT_SET"/>
    116     <attribute name="context-out-dir" default="NOT_SET"/>
    117     <attribute name="context-temp-dir" default="NOT_SET"/>
    118     <attribute name="plugin-out-dir" default="NOT_SET"/>
    119     <element name="build-callers-tasks" implicit="yes" optional="yes"/>
    120     <sequential>
    121       <basename property="@{cshelp-topic}-filenoext" file="@{cshelp-topic}" suffix=".dita"/>
    122       <echo/>
    123       <echo>======================================================</echo>
    124       <echo>START build-cshelp for ${@{cshelp-topic}-filenoext}</echo>
    125       <!-- Call DITA-OT build script to build cshelp topics using special XSL-->
    126       <ant antfile="${dita.dir}/build.xml" target="init">
    127         <property name="args.input" value="@{cshelp-topic}"/>
    128         <property name="dita.input.valfile" value="@{ditaval}"/>
    129         <property name="output.dir" value="@{context-out-dir}"/>
    130         <property name="dita.temp.dir" value="@{context-temp-dir}"/>
    131         <property name="args.xsl" value="${dita.dir}/plugins/cshelp/xsl/dit2context.xsl"/>
    132         <property name="dita.extname" value=".dita"/>
    133         <property name="transtype" value="xhtml"/>
    134         <property name="args.outext" value="xml"/>
    135       </ant>
    136       <!-- Add "topics/" to start of each href so that contexts link to topics in "topics" subfolder-->
    137       <replaceregexp file="@{context-out-dir}/${@{cshelp-topic}-filenoext}.xml"
    138         match="&lt;topic(\s+)href=&#34;" replace="&lt;topic\1href=&#34;topics/"
    139         byline="true"/>
    140       <!-- Move context XML file to this plug-in's output folder-->
    141       <move file="@{context-out-dir}/${@{cshelp-topic}-filenoext}.xml" todir="@{plugin-out-dir}"/>
    142       <!--Load context ext points file, then add it to the end of the plugin.xml file-->
    143       <loadfile property="context-ext-pts" srcfile="${context-file}"/>
    144       <replaceregexp file="@{plugin-out-dir}/plugin.xml" match="&lt;/plugin&gt;"
    145         replace="${context-ext-pts}&lt;/plugin&gt;" byline="yes"/>
    146 
    147       <!--Perform caller's implicit tasks here-->
    148       <build-callers-tasks/>
    149 
    150       <echo>END build-cshelp for ${@{cshelp-topic}-filenoext}</echo>
    151     </sequential>
    152   </macrodef>
    153 
    154   <macrodef name="report" description="Generate debugging report for a ditamap">
    155     <attribute name="map" default="NOT_SET"/>
    156     <sequential>
    157       <if>
    158         <istrue value="${report}"/>
    159         <then>
    160           <exec dir="${basedir}" executable="php" output="${log-dir}/@{map}_debug-report.txt"
    161             os="Mac OS X" failifexecutionfails="false" logerror="true">
    162             <arg file="${dita.dir}/../ditareports/src/ditadebug.php"/>
    163             <arg file="${src-dir}/@{map}"/>
    164           </exec>
    165         </then>
    166       </if>
    167     </sequential>
    168   </macrodef>
    169 
    170   <macrodef name="checklinks" description="Check links in HTML output and generate report">
    171     <attribute name="dir" default="NOT_SET"/>
    172     <attribute name="map" default="NOT_SET"/>
    173     <sequential>
    174       <!--Run linklint if report="true" and if OS is Mac or a Unix-like OS, which ship with Perl.-->
    175       <if>
    176         <and>
    177           <istrue value="${report}"/>
    178           <or>
    179             <os family="mac"/>
    180             <os family="unix"/>
    181           </or>
    182         </and>
    183         <then>
    184           <echo/>
    185           <echo>------------------------------------------------------</echo>
    186           <echo message="linklint:  checking links in output"/>
    187           <exec dir="${basedir}" executable="perl" os="Mac OS X" failifexecutionfails="false"
    188             logerror="true">
    189             <arg file="${dita.dir}/../linklint/src/linklint"/>
    190             <arg value="-root"/>
    191             <arg path="@{dir}"/>
    192             <arg line="/@ -no_warn_index -htmlonly -quiet"/>
    193             <arg value="-doc"/>
    194             <arg path="${log-dir}/@{map}_link-report"/>
    195           </exec>
    196           <echo/>
    197           <echo>See index.html in logs directory for full link report:  ${log-dir}/@{map}_link-report</echo>
    198           <echo>------------------------------------------------------</echo>
    199           <echo/>
    200         </then>
    201       </if>
    202     </sequential>
    203   </macrodef>
    204 
    205   <macrodef name="deleteflagimages" description="Delete flagging images inserted by DITA-OT">
    206     <!--Delete flagging images inserted by DITA-OT because a ditaval file is specified-->
    207     <attribute name="output-dir" default="NOT_SET"/>
    208     <sequential>
    209       <delete file="@{output-dir}/delta.gif"/>
    210       <delete file="@{output-dir}/deltaend.gif"/>
    211     </sequential>
    212   </macrodef>
    213 
    214   <macrodef name="replacecss" description="Replace default CSS">
    215     <!--Delete extraneous CSS from output folder and copy Motorola Dev Ed CSS to output folder..-->
    216     <attribute name="output-dir" default="NOT_SET"/>
    217     <sequential>
    218       <delete file="@{output-dir}/commonrtl.css"/>
    219       <copy file="${basedir}/../../resources/commonltr.css" todir="@{output-dir}" overwrite="yes"/>
    220     </sequential>
    221   </macrodef>
    222 
    223 </project>
    224