i18n/src/messenger/build.xml

454 lines
17 KiB
XML
Raw Normal View History

<project name="mibew messenger" default="usage">
<property name="webim_path" value="webim" />
<property name="closure.c" value="/opt/closure/compiler.jar" />
<property name="handlebars" value="handlebars" />
<property name="dialogs_styles_path" value="${webim_path}/styles/dialogs" />
<property name="js_path" value="${webim_path}/js" />
<!-- Help message about all available targets -->
<target name="usage">
2013-01-18 17:21:17 +04:00
<echo>Available targets:
styles_handlebars - Compile Handlebars templates for dialogs styles
styles_js - Compile JavaScript files for all dialogs styles
styles_all - Run styles_handlebars and styles_js tasks
default_app_js - Build JavaScript files related to default application
chat_app_js - Build JavaScript files related to chat application
invite_app_js - Build JavaScript files related to invite application
thread_log_app_js - Build JavaScript files related to thread log application
users_app_js - Build JavaScript files related to users application
2013-01-18 17:21:17 +04:00
core_handlebars - Compile Handlebars templates of the Core
all - Build everything</echo>
</target>
<!-- Compile Handlebars templates for dialogs styles -->
<target name="styles_handlebars">
<echo>Flatten templates directory structure</echo>
<!-- Use system 'mkdir' instead of ant 'mkdir' task because it do not
work with dirsets -->
<apply executable="mkdir" addsourcefile="false">
<targetfile />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/handlebars_templates" />
</dirset>
<mapper type="glob" from="*/handlebars_templates" to="*/handlebars_templates_tmp" />
</apply>
<!-- Flatten templates directory structure -->
2013-03-01 17:59:38 +04:00
<apply executable="tools/flat_cp" force="true">
<srcfile />
<targetfile />
<arg value="handlebars_templates" />
<fileset dir=".">
<include name="${dialogs_styles_path}/*/handlebars_templates/**/*.handlebars" />
</fileset>
<mapper type="regexp" from="^(.*)/handlebars_templates/(.*)$$" to="\1/handlebars_templates_tmp" />
</apply>
<echo>Compile templates</echo>
<!-- Compile templates -->
<apply executable="${handlebars}">
<arg value="-f"/>
<targetfile />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/handlebars_templates_tmp" />
</dirset>
<mapper type="glob" from="*/handlebars_templates_tmp" to="*/js/compiled/templates_tmp.js" />
</apply>
<!-- Use closule compiler instead of handlebars minifyer (-m flag)
because of handlebars not insert line breaks.
Very long lines are cutted by ant and this brings problems -->
<apply executable="java">
<arg value="-jar" />
<arg value="${closure.c}" />
<arg value="--js" />
<srcfile />
<arg value="--js_output_file" />
<targetfile />
<fileset dir=".">
<include name="${dialogs_styles_path}/*/js/compiled/templates_tmp.js" />
</fileset>
<mapper type="glob" from="*_tmp.js" to="*_tmp.c.js" />
</apply>
<!-- Add license info. Use move because of it is the best way to append
some info to files -->
<move todir="${dialogs_styles_path}" overwrite="true">
<fileset dir="${dialogs_styles_path}"/>
<mapper type="glob" from="*/js/compiled/templates_tmp.c.js" to="*/js/compiled/templates.js"/>
<filterchain>
<!-- Add header -->
<concatfilter prepend="tools/compiled_templates_header.txt" />
<!-- Skip empty lines -->
<linecontainsregexp negate="true">
<regexp pattern="^\s+$$" />
</linecontainsregexp>
</filterchain>
</move>
<!-- Remove all temporary files -->
<!-- Use system 'rm' instead of ant
'delete' task because it do not work with dirsets -->
<echo>Remove temporary files</echo>
<apply executable="rm">
<arg value="-r" />
<arg value="-f" />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/handlebars_templates_tmp" />
</dirset>
</apply>
<delete>
<fileset dir=".">
<include name="${dialogs_styles_path}/*/js/compiled/templates_tmp.js" />
</fileset>
</delete>
<echo>Done</echo>
</target>
<!-- Compile and concatenate JavaScript files for dialog styles -->
<target name="styles_js">
<echo>Compile and concatenate JavaScript files for dialogs styles:</echo>
<!-- Create temporary directories for compiled JavaScript files -->
<echo>Create temporary directories</echo>
<apply executable="mkdir" addsourcefile="false">
<targetfile />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/js/source" />
</dirset>
<mapper type="glob" from="*/source" to="*/tmp" />
</apply>
<!-- Compile JavaScript files -->
<echo>Compile JavaScript files</echo>
<apply executable="java">
<arg value="-jar" />
<arg value="${closure.c}" />
<arg value="--js" />
<srcfile />
<arg value="--js_output_file" />
<targetfile />
<fileset dir=".">
<include name="${dialogs_styles_path}/*/js/source/*.js" />
</fileset>
<mapper type="regexp" from="^(.+)/source/(.+)$$" to="\1/tmp/\2" />
</apply>
<!-- Concatenate all scripts in one file. Use special script for
expanding wildcards. -->
<echo>Concatenate JavaScript files</echo>
2013-03-01 17:59:38 +04:00
<apply executable="tools/cat">
<srcfile suffix="/*.js"/>
<targetfile />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/js/tmp" />
</dirset>
<mapper type="glob" from="*/tmp" to="*/compiled/scripts.js" />
</apply>
<!-- Remove temporary directories -->
<echo>Remove temporary directories</echo>
<apply executable="rm">
<arg value="-r" />
<arg value="-f" />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/js/tmp" />
</dirset>
</apply>
<echo>Done</echo>
</target>
<!-- Build all stuff related to dialogs styles -->
<target name="styles_all" depends="styles_handlebars,styles_js">
<echo>Dialogs styles built.</echo>
</target>
<!-- Compile all JavaScript files of the Mibew Core -->
<target name="compile_js">
<echo>Compile JavaScript files of the Mibew Core</echo>
<!-- Copy directory tree from source to compiled -->
<echo>Copy directory tree</echo>
<copy todir="${js_path}/compiled">
<dirset dir="${js_path}/source">
<include name="**" />
</dirset>
</copy>
<!-- Compile JavaScript files -->
<echo>Compile JavaScript files</echo>
<apply executable="java">
<arg value="-jar" />
<arg value="${closure.c}" />
<arg value="--js" />
<srcfile />
<arg value="--js_output_file" />
<targetfile />
<fileset dir=".">
<include name="${js_path}/source/**/*.js" />
</fileset>
<mapper type="regexp" from="^(.+)/source/(.+)$$" to="\1/compiled/\2" />
</apply>
<echo>Done</echo>
</target>
<!-- Build JavaScript application -->
<target name="app_js" depends="core_handlebars">
<echo>Build "${app_name}" JavaScript application</echo>
<!-- Remove old application file -->
<delete file="${js_path}/compiled/${app_name}_app.js" />
<!-- Append application files to the result file -->
<concat destfile="${js_path}/compiled/${app_name}_app.js" eol="lf">
<!-- Append templates -->
<filelist dir="${js_path}/templates/compiled" files="${app_name}_app.tpl.js" />
<!-- Append application static initialization code -->
<filelist dir="${js_path}/compiled/${app_name}" files="init.js" />
<!-- Include files from ${js_path}/compiled/${app_name}/ -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="*.js" />
<exclude name="init.js" />
<exclude name="app.js" />
</fileset>
<!-- Include models files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="models/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="models/**/*.js" />
<!-- Exclude base files -->
<exclude name="models/**/base*.js" />
</fileset>
<!-- Include collections files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="collections/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="collections/**/*.js" />
<!-- Exclude base files -->
<exclude name="collections/**/base*.js" />
</fileset>
<!-- Include models views files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="model_views/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="model_views/**/*.js" />
<!-- Exclude base files -->
<exclude name="model_views/**/base*.js" />
</fileset>
<!-- Include collections views files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="collection_views/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="collection_views/**/*.js" />
<!-- Exclude base files -->
<exclude name="collection_views/**/base*.js" />
</fileset>
<!-- Include regions files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="regions/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="regions/**/*.js" />
<!-- Exclude base files -->
<exclude name="regions/**/base*.js" />
</fileset>
<!-- Include layouts files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="layouts/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="layouts/**/*.js" />
<!-- Exclude base files -->
<exclude name="layouts/**/base*.js" />
</fileset>
<!-- Include all other files -->
<fileset dir="${js_path}/compiled/${app_name}">
<include name="**/base*.js" />
<exclude name="models/**/base*.js" />
<exclude name="collections/**/base*.js" />
<exclude name="model_views/**/base*.js" />
<exclude name="collection_views/**/base*.js" />
<exclude name="regions/**/base*.js" />
<exclude name="layouts/**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="**/*.js" />
<!-- Exclude files from ${js_path}/compiled/${app_name}/ -->
<exclude name="*.js" />
<!-- Exclude models, collections, views, regions and layouts
files -->
<exclude name="models/**/*.js" />
<exclude name="collections/**/*.js" />
<exclude name="model_views/**/*.js" />
<exclude name="collection_views/**/*.js" />
<exclude name="regions/**/*.js" />
<exclude name="layouts/**/*.js" />
<!-- Exclude base files -->
<exclude name="**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="app.js" />
</fileset>
<!-- Apply filters -->
<filterchain>
<!-- Skip empty lines -->
<linecontainsregexp negate="true">
<regexp pattern="^\s+$$" />
</linecontainsregexp>
</filterchain>
</concat>
<echo>Done</echo>
</target>
<!-- Build JavaScript files related to default application -->
<target name="default_app_js" depends="compile_js">
<antcall target="app_js">
<param name="app_name" value="default" />
</antcall>
<echo>Default JavaScript application built.</echo>
</target>
<!-- Compile and concatenate JavaScript files related to chat application -->
<target name="chat_app_js" depends="default_app_js">
<antcall target="app_js">
<param name="app_name" value="chat" />
</antcall>
<echo>Chat JavaScript application built.</echo>
</target>
<!-- Compile and concatenate JavaScript files related to invite application -->
<target name="invite_app_js" depends="default_app_js">
<antcall target="app_js">
<param name="app_name" value="invite" />
</antcall>
<echo>Invite JavaScript application built.</echo>
</target>
<!-- Compile and concatenate JavaScript files related to users application -->
<target name="users_app_js" depends="default_app_js">
<antcall target="app_js">
<param name="app_name" value="users" />
</antcall>
<echo>Users JavaScript application built.</echo>
</target>
<!-- Compile and concatenate JavaScript files related to thread log application -->
<target name="thread_log_app_js" depends="default_app_js">
<antcall target="app_js">
<param name="app_name" value="thread_log" />
</antcall>
<echo>Thread log JavaScript application built.</echo>
</target>
<!-- Compile Handlebars templates of the Core -->
<target name="core_handlebars">
<echo>Compile Handlebars templates of the Core</echo>
<!-- Compile applications templates -->
<apply executable="${handlebars}">
<arg value="-f"/>
<targetfile />
<dirset dir=".">
<include name="${js_path}/templates/source/*" />
</dirset>
<mapper type="regexp" from="^(.*)/source/(.*)$$" to="\1/compiled/\2_app_tmp.tpl.js" />
</apply>
<!-- Build misc files -->
<apply executable="${handlebars}">
<arg value="-f"/>
<targetfile />
<fileset dir=".">
<include name="${js_path}/templates/source/*.handlebars" />
</fileset>
<mapper type="regexp" from="^(.*)/source/(.*)\.handlebars$$" to="\1/compiled/\2_tmp.tpl.js" />
</apply>
<!-- Use closule compiler instead of handlebars minifyer (-m flag)
because of handlebars not insert line breaks.
Very long lines are cutted by ant and this brings problems -->
<apply executable="java">
<arg value="-jar" />
<arg value="${closure.c}" />
<arg value="--js" />
<srcfile />
<arg value="--js_output_file" />
<targetfile />
<fileset dir=".">
<include name="${js_path}/templates/compiled/*_app_tmp.tpl.js" />
</fileset>
<mapper type="glob" from="*_app_tmp.tpl.js" to="*_app_tmp.c.tpl.js" />
</apply>
<!-- Add license info. Use move because of it is the best way to append
some info to files -->
<move todir="${js_path}/templates/compiled" overwrite="true">
<fileset dir="${js_path}/templates/compiled">
<include name="*_tmp.c.tpl.js" />
</fileset>
<mapper type="glob" from="*_tmp.c.tpl.js" to="*.tpl.js"/>
<filterchain>
<!-- Add header -->
<concatfilter prepend="compiled_templates_header.txt" />
<!-- Skip empty lines -->
<linecontainsregexp negate="true">
<regexp pattern="^\s+$$" />
</linecontainsregexp>
</filterchain>
</move>
<!-- Remove all temporary files. -->
<delete>
<fileset dir="${js_path}/templates/compiled">
<include name="*_tmp.tpl.js" />
</fileset>
</delete>
<echo>Done</echo>
</target>
<!-- Build all project -->
<target name="all" depends="chat_app_js,invite_app_js,thread_log_app_js,users_app_js,styles_all">
<echo>Mibew Messenger built.</echo>
</target>
</project>