i18n/src/messenger/build.xml
2013-03-13 15:32:48 +00:00

318 lines
12 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="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
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>
<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.js" />
</apply>
<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>
<!-- Initialization code goes first. Preserve header comment but strip
empty lines -->
<concat destfile="${js_path}/compiled/${app_name}_app.js" eol="lf">
<!-- Append application static initialization code -->
<filelist dir="${js_path}/compiled/${app_name}" files="init.js" />
<!-- Append templates -->
<filelist dir="${js_path}/templates/compiled" files="${app_name}_app.tpl.js" />
<!-- For some reasons handlebars do not add trailing semicolon.
Add it manually -->
<string>;</string>
<!-- Apply filters -->
<filterchain>
<!-- Skip empty lines -->
<linecontainsregexp negate="true">
<regexp pattern="^\s+$$" />
</linecontainsregexp>
</filterchain>
</concat>
<!-- Append application files to the result file -->
<concat destfile="${js_path}/compiled/${app_name}_app.js" eol="lf" append="true">
<!-- 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}/models">
<include name="**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}/models">
<include name="**/*.js" />
<!-- Exclude base files -->
<exclude name="**/base*.js" />
</fileset>
<!-- Include collections files -->
<fileset dir="${js_path}/compiled/${app_name}/collections">
<include name="**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}/collections">
<include name="**/*.js" />
<!-- Exclude base files -->
<exclude name="**/base*.js" />
</fileset>
<!-- Include models views files -->
<fileset dir="${js_path}/compiled/${app_name}/model_views">
<include name="**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}/model_views">
<include name="**/*.js" />
<!-- Exclude base files -->
<exclude name="**/base*.js" />
</fileset>
<!-- Include collections views files -->
<fileset dir="${js_path}/compiled/${app_name}/collection_views">
<include name="**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}/collection_views">
<include name="**/*.js" />
<!-- Exclude base files -->
<exclude name="**/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" />
</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 and views files -->
<exclude name="models/**/*.js" />
<exclude name="collections/**/*.js" />
<exclude name="model_views/**/*.js" />
<exclude name="collection_views/**/*.js" />
<!-- Exclude base files -->
<exclude name="**/base*.js" />
</fileset>
<fileset dir="${js_path}/compiled/${app_name}">
<include name="app.js" />
</fileset>
<!-- Apply filters -->
<filterchain>
<stripjavacomments />
<!-- 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 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.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.tpl.js" />
</apply>
<echo>Done</echo>
</target>
<!-- Build all project -->
<target name="all" depends="chat_app_js,thread_log_app_js,users_app_js,styles_all">
<echo>Mibew Messenger built.</echo>
</target>
</project>