tray/src/messenger/build.xml
2013-03-13 15:38:25 +00:00

383 lines
14 KiB
XML

<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">
<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
core_handlebars - Compile Handlebars templates of the Core
all - Build everything</echo>
</target>
<!-- Compile Handlebars templates for dialogs styles -->
<target name="styles_handlebars">
<echo>Compile Handlebars templates for dialogs styles</echo>
<!-- Compile templates -->
<apply executable="${handlebars}">
<arg value="-m"/>
<arg value="-f"/>
<targetfile />
<dirset dir=".">
<include name="${dialogs_styles_path}/*/handlebars_templates" />
</dirset>
<mapper type="glob" from="*/handlebars_templates" to="*/js/compiled/templates_tmp.js" />
</apply>
<!-- Appent license info -->
<move todir="${dialogs_styles_path}" overwrite="true">
<fileset dir="${dialogs_styles_path}"/>
<mapper type="glob" from="*/js/compiled/templates_tmp.js" to="*/js/compiled/templates.js"/>
<filterchain>
<!-- Remove comments -->
<stripjavacomments />
<!-- Add header -->
<concatfilter prepend="compiled_templates_header.txt" />
<!-- Skip empty lines -->
<linecontainsregexp negate="true">
<regexp pattern="^\s+$$" />
</linecontainsregexp>
</filterchain>
</move>
<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>
<apply executable="build_scripts/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>
<!-- Build applications templates -->
<apply executable="${handlebars}">
<arg value="-m"/>
<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="-m"/>
<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>
<!-- Add licanse info -->
<move todir="${js_path}/templates/compiled" overwrite="true">
<fileset dir="${js_path}/templates/compiled">
<include name="*_tmp.tpl.js" />
</fileset>
<mapper type="glob" from="*_tmp.tpl.js" to="*.tpl.js"/>
<filterchain>
<!-- Remove comments -->
<stripjavacomments />
<!-- For some reasons handlebars do not add trailing semicolon.
Assume that where is only one line in file and add semicolon
manually -->
<suffixlines suffix=";" />
<!-- Add header -->
<concatfilter prepend="compiled_templates_header.txt" />
<!-- Skip empty lines -->
<linecontainsregexp negate="true">
<regexp pattern="^\s+$$" />
</linecontainsregexp>
</filterchain>
</move>
<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>