<?xml version="1.0" encoding="utf-8"?><!-- This file is part of the DITA Open Toolkit project hosted on 
     Sourceforge.net. See the accompanying license.txt file for 
     applicable licenses.--><!-- (c) Copyright IBM Corp. 2006 All Rights Reserved. --><project name="dita2eclipsehelp" default="dita2eclipsehelp">
    <property name="transtype" value="eclipsehelp"></property>
    
    <import file="build_init.xml"></import>
    <import file="build_preprocess.xml"></import>
    <import file="build_general.xml"></import>
	
	   <target name="dita.index.eclipsehelp.init">
	      <condition property="dita.eclipsehelp.index.class" value="org.dita.dost.writer.EclipseIndexWriter"> 
	          <not><isset property="dita.eclipsehelp.index.class"></isset></not> 
	      </condition> 
	   </target>
	
	
    <target name="dita2eclipsehelp" unless="noMap" depends="build-init, preprocess, copy-css,                       dita.topics.xhtml, dita.inner.topics.xhtml, dita.outer.topics.xhtml">
      <antcall target="dita.map.eclipse"></antcall>
    </target>

    <!--<target name="dita.map.eclipse"
        depends="dita.map.eclipse.init, dita.map.eclipse.toc, dita.map.eclipse.index, dita.map.eclipse.plugin, dita.out.map.eclipse.toc, dita.out.map.eclipse.index, dita.out.map.eclipse.plugin" />-->

  <target name="dita.map.eclipse" depends=" dita.map.eclipse.init, copy-plugin-files, dita.map.eclipse.fragment.language.init, dita.map.eclipse.fragment.language.country.init, dita.map.eclipse.fragment.error">
    
  </target>
	
	<target name="dita.map.eclipse.init" if="eclipse.plugin" depends="dita.map.eclipse.plugin.init">
	                <antcall target="dita.map.eclipse.generate.plugin"></antcall>                     
	</target>

    <target name="dita.map.eclipse.plugin.init" description="Init properties for EclipseHelp">
        <basename property="dita.map.toc.root" file="${dita.input.filename}" suffix=".ditamap"></basename>
        <condition property="args.eclipsehelp.toc" value="${dita.map.toc.root}">
            <not>
                <isset property="args.eclipsehelp.toc"></isset>
            </not>
        </condition>
        <condition property="out.ext" value=".html">
            <not>
                <isset property="out.ext"></isset>
            </not>
        </condition>
        <condition property="noPlugin">
            <equals arg1="${dita.eclipse.plugin}" arg2="no"></equals>
        </condition>
      <condition property="eclipse.fragment.language">
        <and>
          <isset property="args.eclipsehelp.language"></isset>
          <not>
            <isset property="args.eclipsehelp.country"></isset>
          </not>
        </and>
      </condition>
      <condition property="eclipse.fragment.country">
        <and>
          <isset property="args.eclipsehelp.language"></isset>
          <isset property="args.eclipsehelp.country"></isset>
        </and>
      </condition>
      
      <condition property="eclipse.plugin">
        <not>
          <or>
            <isset property="args.eclipsehelp.language"></isset>
            <isset property="args.eclipsehelp.country"></isset>
            <and>
              <isset property="args.eclipsehelp.country"></isset>
              <isset property="args.eclipsehelp.language"></isset>
            </and>
          </or>
        </not>
      </condition>
      <condition property="eclipse.fragment.error">
        <and>
          <isset property="args.eclipsehelp.country"></isset>
          <not>
            <isset property="args.eclipsehelp.language"></isset>
          </not>
        </and>
      </condition>
    	<condition property="args.eclipsehelp.indexsee" value="false">
    	    <not>
    	      <isset property="args.eclipsehelp.indexsee"></isset>
    	    </not>
    	</condition>
    </target>

    <target name="dita.map.eclipse.toc" unless="noMap" depends="dita.map.eclipse.plugin.init" if="old.transform" description="Build EclipseHelp TOC file">
        <xslt processor="trax" basedir="${dita.temp.dir}" destdir="${output.dir}" includesfile="${dita.temp.dir}${file.separator}${fullditamapfile}" extension=".xml" classpathref="dost.class.path" style="${dita.script.dir}${file.separator}map2eclipse.xsl">
        	<excludesfile name="${dita.temp.dir}${file.separator}${resourceonlyfile}" if="resourceonlyfile"></excludesfile>
            <includesfile name="${dita.temp.dir}${file.separator}${chunkedditamapfile}" if="chunkedditamapfile"></includesfile>
            <param name="DITAEXT" expression="${dita.ext}" if="dita.ext"></param>
            <param name="OUTEXT" expression="${out.ext}" if="out.ext"></param>
            <param name="WORKDIR" expression="${workdir}" if="workdir"></param>
        </xslt>
    </target>
    
    <target name="dita.out.map.eclipse.toc" unless="noMap" depends="dita.map.eclipse.plugin.init" if="inner.transform" description="Build EclipseHelp TOC file">
        <xslt processor="trax" basedir="${dita.temp.dir}" destdir="${output.dir}" includesfile="${dita.temp.dir}${file.separator}${fullditamapfile}" classpathref="dost.class.path" style="${dita.script.dir}${file.separator}map2eclipse.xsl">
        	<excludesfile name="${dita.temp.dir}${file.separator}${resourceonlyfile}" if="resourceonlyfile"></excludesfile>
            <includesfile name="${dita.temp.dir}${file.separator}${chunkedditamapfile}" if="chunkedditamapfile"></includesfile>
            <param name="DITAEXT" expression="${dita.ext}" if="dita.ext"></param>
            <param name="OUTEXT" expression="${out.ext}" if="out.ext"></param>
            <param name="WORKDIR" expression="${workdir}" if="workdir"></param>
            <mapper type="regexp" from="^(${tempdirToinputmapdir.relative.value})(.*?)(\.ditamap)$$" to="\2\.xml"></mapper>
        </xslt>
    </target>
    
    <target name="dita.map.eclipse.index" unless="noMap" if="old.transform" depends="dita.index.eclipsehelp.init,dita.map.eclipse.plugin.init,dita.index.eclipsehelp.init" description="Build Eclipse Help index file">
    	  <echo level="info"> args.eclipsehelp.indexsee = ${args.eclipsehelp.indexsee} </echo>
    	  <pipeline message="Extract index term." module="IndexTermExtract" basedir="${basedir}" tempdir="${dita.temp.dir}" inputmap="${user.input.file}">
          <param name="output" location="${output.dir}${file.separator}${user.input.file}"></param>
          <param name="targetext" value="${out.ext}"></param>
          <param name="indextype" value="eclipsehelp"></param>
          <param name="indexclass" value="${dita.eclipsehelp.index.class}"></param>
          <param name="eclipse.indexsee" value="${args.eclipsehelp.indexsee}"></param>
          <param name="encoding" value="${args.dita.locale}" if="args.dita.locale"></param>
    	  </pipeline>
    </target>
    
    <target name="dita.out.map.eclipse.index" unless="noMap" if="inner.transform" depends="dita.index.eclipsehelp.init,dita.map.eclipse.plugin.init,dita.index.eclipsehelp.init" description="Build Eclipse Help index file">
    	  <echo level="info"> args.eclipsehelp.indexsee = ${args.eclipsehelp.indexsee} </echo>
        <pipeline message="Extract index term." module="IndexTermExtract" basedir="${basedir}" tempdir="${dita.temp.dir}" inputmap="${user.input.file}">
          <param name="output" location="${output.dir}${file.separator}index.xml"></param>
          <param name="targetext" value="${out.ext}"></param>
          <param name="indextype" value="eclipsehelp"></param>
          <param name="indexclass" value="${dita.eclipsehelp.index.class}"></param>
          <param name="eclipse.indexsee" value="${args.eclipsehelp.indexsee}"></param>
          <param name="encoding" value="${args.dita.locale}" if="args.dita.locale"></param>
        </pipeline>
    </target>

    <target name="dita.map.eclipse.plugin" unless="noPlugin" depends="dita.map.eclipse.plugin.init" if="old.transform" description="Build Eclipsehelp plugin file">
        <xslt processor="trax" in="${dita.temp.dir}${file.separator}${user.input.file}" out="${dita.map.output.dir}${file.separator}plugin.xml" classpathref="dost.class.path" style="${dita.script.dir}${file.separator}map2plugin.xsl">
            <param name="TOCROOT" expression="${args.eclipsehelp.toc}"></param>
            <param name="version" expression="${args.eclipse.version}" if="args.eclipse.version"></param>
            <param name="provider" expression="${args.eclipse.provider}" if="args.eclipse.provider"></param>
        	  <param name="osgi.symbolic.name" expression="${args.eclipse.symbolic.name}" if="args.eclipse.symbolic.name"></param>
        	  <outputproperty value="yes" name="indent"></outputproperty>
        	  <param name="dita.plugin.output" expression="dita.eclipse.plugin"></param>  
        </xslt>
    </target>
    
    <target name="dita.out.map.eclipse.plugin" unless="noPlugin" depends="dita.map.eclipse.plugin.init" if="inner.transform" description="Build Eclipsehelp plugin file">
        <xslt processor="trax" in="${dita.temp.dir}${file.separator}${user.input.file}" out="${output.dir}${file.separator}plugin.xml" classpathref="dost.class.path" style="${dita.script.dir}${file.separator}map2plugin.xsl">
            <param name="TOCROOT" expression="${args.eclipsehelp.toc}"></param>
            <param name="version" expression="${args.eclipse.version}" if="args.eclipse.version"></param>
            <param name="provider" expression="${args.eclipse.provider}" if="args.eclipse.provider"></param>
        	  <param name="osgi.symbolic.name" expression="${args.eclipse.symbolic.name}" if="args.eclipse.symbolic.name"></param>
        	  <outputproperty value="yes" name="indent"></outputproperty>
        	  <param name="dita.plugin.output" expression="dita.eclipse.plugin"></param>  
        </xslt>
    </target>
  
  <!-- New support for creating Eclipse fragments based on the similar map used to create a plug-in -->
  
  
  
  <target name="dita.map.eclipse.manifest.file" unless="noPlugin" depends="dita.map.eclipse.plugin.init" if="old.transform" description="Build Eclipsehelp manifest.mf file">
    <xslt processor="trax" in="${dita.temp.dir}${file.separator}${user.input.file}" out="${dita.map.output.dir}${file.separator}META-INF${file.separator}MANIFEST.MF" classpathref="dost.class.path" style="${dita.script.dir}${file.separator}map2plugin.xsl">
      <param name="version" expression="${args.eclipse.version}" if="args.eclipse.version"></param>
      <param name="provider" expression="${args.eclipse.provider}" if="args.eclipse.provider"></param>
    	<param name="osgi.symbolic.name" expression="${args.eclipse.symbolic.name}" if="args.eclipse.symbolic.name"></param>
      <param name="plugin" expression="${eclipse.plugin}"></param>
      <param name="fragment.country" expression="${args.eclipsehelp.country}" if="eclipse.fragment.country"></param>
      <param name="fragment.lang" expression="${args.eclipsehelp.language}" if="args.eclipsehelp.language"></param>
      <outputproperty value="text" name="method"></outputproperty>
      <param name="dita.plugin.output" expression="dita.eclipse.manifest"></param>                
    </xslt>
  </target>
  
  <target name="dita.out.map.eclipse.manifest.file" unless="noPlugin" depends="dita.map.eclipse.plugin.init" if="inner.transform" description="Build Eclipsehelp manifest.mf file">
    <xslt processor="trax" in="${dita.temp.dir}${file.separator}${user.input.file}" out="${dita.map.output.dir}${file.separator}META-INF${file.separator}MANIFEST.MF" classpathref="dost.class.path" style="${dita.script.dir}${file.separator}map2plugin.xsl">
      <param name="version" expression="${args.eclipse.version}" if="args.eclipse.version"></param>
      <param name="provider" expression="${args.eclipse.provider}" if="args.eclipse.provider"></param>
    	<param name="osgi.symbolic.name" expression="${args.eclipse.symbolic.name}" if="args.eclipse.symbolic.name"></param>
      <param name="plugin" expression="${eclipse.plugin}"></param>
      <param name="fragment.country" expression="${args.eclipsehelp.country}" if="eclipse.fragment.country"></param>
      <param name="fragment.lang" expression="${args.eclipsehelp.language}" if="args.eclipsehelp.language"></param>
      <outputproperty value="text" name="method"></outputproperty>
      <param name="dita.plugin.output" expression="dita.eclipse.manifest"></param>                
    </xslt>
  </target>
  
  
  <target name="dita.map.eclipse.plugin.properties" unless="noPlugin" depends="dita.map.eclipse.plugin.init" if="old.transform" description="Create eclipse plugin.properties file">
    <xslt processor="trax" in="${dita.temp.dir}${file.separator}${user.input.file}" out="${output.dir}${file.separator}plugin.properties" classpathref="dost.class.path" style="${dita.script.dir}${file.separator}map2plugin.xsl">
      <outputproperty value="text" name="method"></outputproperty>
      <param name="dita.plugin.output" expression="dita.eclipse.properties"></param>
    	<param name="version" expression="${args.eclipse.version}" if="args.eclipse.version"></param>
    	<param name="provider" expression="${args.eclipse.provider}" if="args.eclipse.provider"></param>
    </xslt>
  </target>
  
  <target name="dita.out.map.eclipse.plugin.properties" unless="noPlugin" depends="dita.map.eclipse.plugin.init" if="inner.transform" description="Create eclipse plugin.properties file">
    <xslt processor="trax" in="${dita.temp.dir}${file.separator}${user.input.file}" out="${output.dir}${file.separator}plugin.properties" classpathref="dost.class.path" style="${dita.script.dir}${file.separator}map2plugin.xsl">
      <outputproperty value="text" name="method"></outputproperty>
      <param name="dita.plugin.output" expression="dita.eclipse.properties"></param>
    	<param name="version" expression="${args.eclipse.version}" if="args.eclipse.version"></param>
      <param name="provider" expression="${args.eclipse.provider}" if="args.eclipse.provider"></param>
    </xslt>
  </target>
  
  <target name="dita.map.eclipse.fragment.language.init" if="eclipse.fragment.language" depends="dita.map.eclipse.plugin.init">
    <property name="fragment.dirname.init" value="nl"></property>
    <property name="fragment.dirname" value="${fragment.dirname.init}${file.separator}${args.eclipsehelp.language}"></property>
    <property name="fragment.property.name" value="${args.eclipsehelp.language}"></property>
    <antcall target="dita.map.eclipse.genetrate.fragment"></antcall>
  </target>
  
  <target name="dita.map.eclipse.fragment.language.country.init" if="eclipse.fragment.country" depends="dita.map.eclipse.plugin.init">
    <property name="fragment.dirname.init" value="nl"></property>
    <property name="fragment.dirname" value="${fragment.dirname.init}${file.separator}${args.eclipsehelp.language}${file.separator}${args.eclipsehelp.country}"></property>
    <property name="fragment.property.name" value="${args.eclipsehelp.language}_${args.eclipsehelp.country}"></property>
    <antcall target="dita.map.eclipse.genetrate.fragment"></antcall>
  </target>
	
	<target name="dita.map.eclipse.fragment.error" if="eclipse.fragment.error" depends="dita.map.eclipse.plugin.init">
	            <echo message="The Eclipse Fragment property args.eclipsehelp.language was not set. "></echo>
	</target>
  
  <target name="dita.map.eclipse.fragment.move.files" if="old.transform">
    <defaultexcludes add="**/META-INF/**"></defaultexcludes>
    <defaultexcludes add="**/nl/**"></defaultexcludes>
  	<delete file="${output.dir}${file.separator}plugin.xml"></delete>
  	<delete file="${output.dir}${file.separator}plugincustomization.ini"></delete>
    <move todir="${dita.map.output.dir}${file.separator}${fragment.dirname}" includeemptydirs="yes">
      <fileset dir="${dita.map.output.dir}" defaultexcludes="yes">
        <exclude name="helpData.xml"></exclude>
      	<exclude name="plugin.properties"></exclude>
      	<exclude name="plugin_${fragment.property.name}.properties"></exclude>
        <exclude name="*.list"></exclude>
      	<exclude name="disabled_book.css"></exclude>
      	<exclude name="narrow_book.css"></exclude>
      	<exclude name="${os}_narrow_book.css"></exclude>
      	<exclude name="book.css"></exclude>
      	<exclude name="plugincustomization.ini"></exclude>
      </fileset>
    </move>
  	<move file="${output.dir}${file.separator}plugin.properties" tofile="${output.dir}${file.separator}plugin_${fragment.property.name}.properties" failonerror="no"></move>

  	
  </target>
  
  <target name="dita.out.map.eclipse.fragment.move.files" if="inner.transform">
    <defaultexcludes add="**/META-INF/**"></defaultexcludes>
    <defaultexcludes add="**/nl/**"></defaultexcludes>
  	<delete file="${output.dir}${file.separator}plugin.xml"></delete>
  	<delete file="${output.dir}${file.separator}plugincustomization.ini"></delete>
    <move todir="${output.dir}${file.separator}${fragment.dirname}" includeemptydirs="yes">
      <fileset dir="${output.dir}" defaultexcludes="yes">
        <exclude name="helpData.xml"></exclude>
      	<exclude name="plugin.properties"></exclude>
      	<exclude name="plugin_${fragment.property.name}.properties"></exclude>
        <exclude name="*.list"></exclude>
      	<exclude name="disabled_book.css"></exclude>
      	<exclude name="narrow_book.css"></exclude>
      	<exclude name="${os}_narrow_book.css"></exclude>
      	<exclude name="book.css"></exclude>
      	<exclude name="plugincustomization.ini"></exclude>
      </fileset>
    </move>
  	<move file="${output.dir}${file.separator}plugin.properties" tofile="${output.dir}${file.separator}plugin_${fragment.property.name}.properties" failonerror="no"></move>
  </target>
  
  <!--<target name="dita.map.eclipse"
    depends="dita.map.eclipse.init, 
    dita.map.eclipse.toc, 
    dita.map.eclipse.index, 
    dita.map.eclipse.plugin, 
    dita.out.map.eclipse.toc, 
    dita.out.map.eclipse.index, 
    dita.out.map.eclipse.plugin" />
  -->
  
  <target name="dita.map.eclipse.generate.plugin" depends="dita.map.eclipse.toc,      dita.map.eclipse.index,     dita.map.eclipse.plugin,     dita.map.eclipse.plugin.properties,      dita.map.eclipse.manifest.file,     dita.out.map.eclipse.plugin.properties,      dita.out.map.eclipse.manifest.file,     dita.out.map.eclipse.toc,      dita.out.map.eclipse.index,      dita.out.map.eclipse.plugin">
    
  </target>
  

  
  <target name="dita.map.eclipse.genetrate.fragment" depends="dita.map.eclipse.toc,      dita.map.eclipse.index,      dita.map.eclipse.plugin.properties,      dita.map.eclipse.manifest.file,      dita.out.map.eclipse.plugin.properties,      dita.out.map.eclipse.manifest.file,      dita.out.map.eclipse.toc,      dita.out.map.eclipse.index,      dita.out.map.eclipse.plugin,     dita.map.eclipse.fragment.move.files,     dita.out.map.eclipse.fragment.move.files">
    
  </target>

    <!-- depecrated: keep for back-compatibility, will be remvoed in a later release -->
    <target name="dita.topics.eclipse" depends="dita.topics.xhtml"></target>
	
	<target name="copy-plugin-files">
	  	<!-- Look for files that override behavior in Eclipse plugins -->
	  	<!-- <echo>* dita.input.dirname = ${user.input.dir}</echo> -->
	  	<copy todir="${output.dir}">
	  	      <fileset dir="${user.input.dir}">
	  	      	<include name="disabled_book.css"></include>
	  	        <include name="narrow_book.css"></include>
	  	        <include name="${os}_narrow_book.css"></include>
	  	        <include name="book.css"></include>
	  	        <include name="plugincustomization.ini"></include>
	  	        <include name="helpData.xml"></include>
	  	      </fileset>
	  		  
	  	</copy>
	</target>

</project>