|
1 | 1 | <project name="jQuery.Tools" default="min"> |
2 | 2 |
|
3 | | - <taskdef resource="net/sf/antcontrib/antlib.xml"/> |
| 3 | + <taskdef resource="net/sf/antcontrib/antlib.xml"/> |
| 4 | + <property file="build.properties" prefix="v"/> |
4 | 5 |
|
5 | | - <property name="dir" value="/home/tipiirai/svn/flowplayer"/> |
6 | | - <property file="${dir}/www/trunk/etc/version.properties" prefix="v"/> |
7 | | - <property name="rhino" value="${dir}/builder/lib/rhino.jar"/> |
8 | | - <property name="target.dir" value="/opt/flowplayer/webapp/js/tools"/> |
9 | | - <property name="yui.path" value="/opt/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar"/> |
10 | | - |
11 | | - |
12 | | - <target name="closure"> |
| 6 | + <property name="www" value="${v.www}-${v.tools}"/> |
| 7 | + <property name="js" value="${www}/js"/> |
| 8 | + <property name="build" value="build/${v.tools}"/> |
13 | 9 |
|
14 | | - <apply |
15 | | - executable="/usr/lib/jvm/java-6-sun-1.6.0.10/bin/java" |
16 | | - parallel="false" |
17 | | - verbose="true" |
18 | | - dest="src"> |
19 | | - |
20 | | - <fileset dir="src" includes="form/*.js"/> |
21 | | - <arg line="-jar"/> |
22 | | - <arg path="lib/compiler.jar"/> |
23 | | - <arg line="--js"/> |
24 | | - <srcfile/> |
25 | | - <arg line="--js_output_file"/> |
26 | | - <mapper type="glob" from="*.js" to="../build/*.min.js"/> |
27 | | - <targetfile/> |
28 | | - </apply> |
| 10 | + <!-- replace @VERSION and @DATE tags --> |
| 11 | + <target name="sources"> |
| 12 | + |
| 13 | + <!-- copy sources to build directory --> |
| 14 | + <mkdir dir="${build}"/> |
| 15 | + <copy todir="${build}"> |
| 16 | + <fileset dir="src"/> |
| 17 | + </copy> |
29 | 18 |
|
30 | | - </target> |
31 | | - |
32 | | - <target name="loop"> |
33 | | - <for param="file"> |
34 | 19 |
|
| 20 | + <!-- loop trough them --> |
| 21 | + <for param="file"> |
35 | 22 | <path> |
36 | | - <fileset dir="${basedir}" includes="**/tools.*.js"/> |
| 23 | + <fileset dir="${build}" includes="*/*.js" excludes="*/*.min.js"/> |
37 | 24 | </path> |
38 | 25 |
|
39 | 26 | <sequential> |
40 | | - <!-- source file --> |
41 | | - <var name="sourceFile" value="@{file}"/> |
42 | | - |
43 | | - <!-- tool name --> |
44 | | - <propertyregex input="@{file}" override="yes" property="tool" replace="\1" |
45 | | - regexp=".*tools.(.*)\.js"/> |
46 | | - |
47 | | - <!-- version number --> |
| 27 | + |
| 28 | + <!-- version number --> |
| 29 | + <propertyregex property="tool" input="@{file}" override="yes" replace="\1" |
| 30 | + regexp=".+/(.*)\.js"/> |
| 31 | + |
48 | 32 | <propertycopy name="version" from="v.${tool}" override="yes"/> |
49 | | - |
50 | | - <!-- base file name --> |
51 | | - <var name="base" value="${target.dir}/tools.${tool}-${version}"/> |
52 | | - |
53 | | - <!-- only process if the source file is modified --> |
54 | | - <outofdate property="isModified"> |
55 | | - <sourcefiles path="@{file}"/> |
56 | | - <targetfiles path="${base}.js"/> |
57 | | - |
58 | | - <sequential> |
59 | | - <antcall target="${target}"/> |
60 | | - </sequential> |
| 33 | + |
| 34 | + <replaceregexp match="@VERSION" replace="${version}" flags="g" byline="true" |
| 35 | + file="@{file}" /> |
61 | 36 |
|
62 | | - </outofdate> |
| 37 | + |
| 38 | + <!-- last modified (via <git log> command) --> |
| 39 | + <propertyregex property="source" input="@{file}" override="yes" replace="\1" |
| 40 | + regexp=".+/\d.\d.\d/(.*)\.js"/> |
| 41 | + |
| 42 | + <exec executable="git" outputproperty="git.log" > |
| 43 | + <arg line="log src/${source}.js"/> |
| 44 | + </exec> |
| 45 | + |
| 46 | + <propertyregex property="date" input="${git.log}" select="\1"> |
| 47 | + <regexp pattern="Date:(.+)"/> |
| 48 | + </propertyregex> |
| 49 | + |
| 50 | + <replaceregexp match="@DATE" replace="${date}" file="@{file}" /> |
63 | 51 |
|
64 | 52 | </sequential> |
65 | 53 | </for> |
66 | | - |
67 | | - </target> |
68 | | - |
69 | | - <!-- source code --> |
70 | | - <target name="source"> |
71 | | - |
72 | | - <copy file="${sourceFile}" tofile="${base}.js"/> |
73 | | - |
74 | | - <!-- <exec executable="svn" outputproperty="svnlog.out" > |
75 | | - <arg line="info ${sourceFile}"/> |
76 | | - </exec> --> |
77 | | - |
78 | | - <propertyregex property="revision" input="${svnlog.out}" select="\1"> |
79 | | - <regexp pattern="Revision: ([0-9]*)"/> |
80 | | - </propertyregex> |
81 | | - |
82 | | - <propertyregex property="date" input="${svnlog.out}" select="\1"> |
83 | | - <regexp pattern="Date: (.+\))"/> |
84 | | - </propertyregex> |
85 | | - |
86 | | - <replaceregexp match="@VERSION" replace="${version}" flags="g" byline="true" |
87 | | - file="${base}.js" /> |
88 | | - |
89 | | - <replaceregexp match="@DATE" replace="${date}" file="${base}.js" /> |
90 | | - <replaceregexp match="@REVISION" replace="${revision}" file="${base}.js" /> |
91 | | - <echo message="Source code: ${base}.js" /> |
92 | | - |
93 | | - </target> |
94 | | - |
95 | | - <!-- minify --> |
96 | | - <target name="min"> |
97 | | - <property name="target" value="min.do"/> |
98 | | - <antcall target="loop"/> |
99 | | - </target> |
| 54 | + </target> |
100 | 55 |
|
101 | | - <!-- yuicompress: http://www.julienlecomte.net/blog/2007/09/16/ --> |
102 | | - <target name="min.do" depends="source"> |
103 | 56 |
|
104 | | - <apply executable="java" parallel="false"> |
105 | | - <fileset file="${base}.js"/> |
106 | | - <arg line="-jar"/> |
107 | | - <arg path="${yui.path}"/> |
108 | | - <srcfile/> |
109 | | - <arg line="-o"/> |
110 | | - <mapper type="glob" from="*.js" to="${target.dir}/*.min.js"/> |
111 | | - <targetfile/> |
| 57 | + <!-- minify with Closure Compiler (default mode) --> |
| 58 | + <target name="min" depends="sources"> |
| 59 | + |
| 60 | + <!-- do the hard work --> |
| 61 | + <apply |
| 62 | + executable="java" |
| 63 | + parallel="false" |
| 64 | + verbose="true" |
| 65 | + dest="${build}"> |
| 66 | + |
| 67 | + <fileset dir="${build}" includes="*/*.js" excludes="*/*.min.js"/> |
| 68 | + <arg line="-jar"/> |
| 69 | + <arg path="lib/compiler.jar"/> |
| 70 | + <arg line="--js"/> |
| 71 | + <srcfile/> |
| 72 | + <arg line="--js_output_file"/> |
| 73 | + <mapper type="glob" from="*.js" to="*.min.js"/> |
| 74 | + <targetfile/> |
112 | 75 | </apply> |
113 | 76 |
|
114 | | - <replaceregexp match="/\*!" replace="/\*\*" file="${base}.js" /> |
115 | | - <echo message="Minified: ${base}.min.js"/> |
116 | | - |
117 | 77 | </target> |
118 | 78 |
|
| 79 | + <!-- copy stuff under web folder --> |
| 80 | + <target name="www"> |
119 | 81 |
|
120 | | - <!-- lint --> |
121 | | - <target name="lint"> |
122 | | - <property name="target" value="lint.do"/> |
123 | | - <antcall target="loop"/> |
124 | | - </target> |
| 82 | + <!-- documentation --> |
| 83 | + <mkdir dir="${www}"/> |
| 84 | + <copy todir="${www}"> |
| 85 | + <fileset dir="www"/> |
| 86 | + </copy> |
| 87 | + |
| 88 | + </target> |
125 | 89 |
|
126 | | - <target name="lint.do"> |
127 | | - <echo message="Verifying ${tool}"/> |
128 | | - <java jar="${rhino}" fork="true"> |
129 | | - <arg value="${dir}/builder/lib/jslint.js" /> |
130 | | - <arg value="${sourceFile}" /> |
131 | | - </java> |
| 90 | + <!-- deploy --> |
| 91 | + <target name="deploy" depends="www"> |
| 92 | + |
| 93 | + <!-- zip --> |
| 94 | + <zip destfile="${build}/tools-${v.tools}.zip" |
| 95 | + basedir="${build}" |
| 96 | + excludes="*.zip" /> |
| 97 | + |
| 98 | + <!-- javascript --> |
| 99 | + <mkdir dir="${js}"/> |
| 100 | + <copy todir="${js}"> |
| 101 | + <fileset dir="${build}"/> |
| 102 | + </copy> |
| 103 | + |
| 104 | + <!-- properties --> |
| 105 | + <copy file="build.properties" tofile="${www}/../WEB-INF/tools.properties"/> |
| 106 | + |
132 | 107 | </target> |
| 108 | + |
133 | 109 |
|
134 | 110 | </project> |
135 | 111 |
|
|
0 commit comments