<?xml version="1.0" encoding="UTF-8"?>
<project name="TinyMCE" default="build" basedir=".">
  <!-- Path properties -->
  <property description="Source directory" name="src_dir" value="Products/TinyMCE/skins/tinymce" />
  <property description="Temp directory" name="temp_dir" value="tmp" />

  <!-- Setup classpath for js-build-tools ant tasks -->
  <path id="tasks.classpath">
    <pathelement location="."/>

    <fileset dir="tools">
      <include name="**/*.jar"/>
    </fileset>
  </path>

  <!-- Register new js-build-tools ant tasks -->
  <taskdef name="preprocess" classname="com.moxiecode.ant.tasks.PreProcessTask" classpathref="tasks.classpath" loaderref="tasks.classpath.loader" />
  <taskdef name="yuicompress" classname="com.moxiecode.ant.tasks.YuiCompressTask" classpathref="tasks.classpath" loaderref="tasks.classpath.loader" />
  <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="tasks.classpath" loaderref="tasks.classpath.loader" />

  <!-- Cleanup -->
  <target name="clean" depends="" description="Cleans up the project from temporary files">
    <delete dir="${temp_dir}" quiet="true" />
  </target>

  <!-- Concat and minify -->
  <target name="build" depends="" description="Builds the project">
    <delete dir="${temp_dir}" quiet="true" />

    <copy file="${src_dir}/tiny_mce_src.js" tofile="${temp_dir}/tiny_mce_src.js" />

    <!-- Remove all jsdoc style comments -->
    <replaceregexp match="/\*\*(.*?)\*\/\s*" replace="" flags="gs" byline="false" file="${temp_dir}/tiny_mce_src.js" />

    <!-- Preprocess core -->
    <preprocess infile="${temp_dir}/tiny_mce_src.js" outfile="${temp_dir}/tiny_mce_tmp.js" />

    <!-- Compress core -->
    <yuicompress infile="${temp_dir}/tiny_mce_tmp.js" outfile="${src_dir}/tiny_mce.js" />

    <!-- Cleanup -->
    <delete dir="${temp_dir}" quiet="true" />
  </target>

</project>
