|
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="version.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 | + <!-- hardcoded --> |
| 7 | + <property name="www" value="/opt/flowplayer/webapp/tools-${v.tools}"/> |
| 8 | + <property name="js" value="/opt/flowplayer/webapp/js/tools/${v.tools}"/> |
| 9 | + |
| 10 | + <!-- minify with Closure Compiler (default mode) --> |
| 11 | + <target name="min"> |
13 | 12 |
|
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"> |
| 13 | + <!-- create build directories --> |
| 14 | + <mkdir dir="build/${v.tools}/form"/> |
| 15 | + <mkdir dir="build/${v.tools}/toolbox"/> |
| 16 | + <mkdir dir="build/${v.tools}/overlay"/> |
| 17 | + <mkdir dir="build/${v.tools}/scrollable"/> |
| 18 | + <mkdir dir="build/${v.tools}/tabs"/> |
| 19 | + <mkdir dir="build/${v.tools}/tooltip"/> |
| 20 | + |
| 21 | + <!-- do the hard work --> |
| 22 | + <apply |
| 23 | + executable="java" |
| 24 | + parallel="false" |
| 25 | + verbose="true" |
| 26 | + dest="src"> |
19 | 27 |
|
20 | | - <fileset dir="src" includes="form/*.js"/> |
| 28 | + <fileset dir="src" includes="*/*.js"/> |
21 | 29 | <arg line="-jar"/> |
22 | 30 | <arg path="lib/compiler.jar"/> |
23 | 31 | <arg line="--js"/> |
|
29 | 37 |
|
30 | 38 | </target> |
31 | 39 |
|
32 | | - <target name="loop"> |
33 | | - <for param="file"> |
| 40 | + <!-- copy stuff under web folder --> |
| 41 | + <target name="www"> |
| 42 | + <mkdir dir="${www}"/> |
| 43 | + <copy todir="${www}"> |
| 44 | + <fileset dir="www"/> |
| 45 | + </copy> |
| 46 | + </target> |
34 | 47 |
|
| 48 | + |
| 49 | + <!-- deploy task --> |
| 50 | + <target name="deploy" depends="min"> |
| 51 | + |
| 52 | + <!-- loop trough files and update version number and last modified date --> |
| 53 | + <for param="file"> |
35 | 54 | <path> |
36 | | - <fileset dir="${basedir}" includes="**/tools.*.js"/> |
| 55 | + <fileset dir="build/${v.tools}" includes="*/*.js"/> |
37 | 56 | </path> |
38 | 57 |
|
39 | 58 | <sequential> |
40 | | - <!-- source file --> |
41 | | - <var name="sourceFile" value="@{file}"/> |
42 | | - |
43 | | - <!-- tool name --> |
| 59 | + |
| 60 | + <!-- version number --> |
44 | 61 | <propertyregex input="@{file}" override="yes" property="tool" replace="\1" |
45 | | - regexp=".*tools.(.*)\.js"/> |
46 | | - |
47 | | - <!-- version number --> |
| 62 | + regexp=".+/(.*)\.min.js"/> |
| 63 | + |
48 | 64 | <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> |
| 65 | + |
| 66 | + <replaceregexp match="@VERSION" replace="${version}" flags="g" byline="true" |
| 67 | + file="@{file}" /> |
61 | 68 |
|
62 | | - </outofdate> |
| 69 | + |
| 70 | + <!-- last modified (via <git log> command) --> |
| 71 | + <propertyregex input="@{file}" override="yes" property="source" replace="\1" |
| 72 | + regexp=".+/\d.\d.\d/(.*)\.min.js"/> |
| 73 | + |
| 74 | + <exec executable="git" outputproperty="git.log" > |
| 75 | + <arg line="log src/${source}.js"/> |
| 76 | + </exec> |
| 77 | + |
| 78 | + <propertyregex property="date" input="${git.log}" select="\1"> |
| 79 | + <regexp pattern="Date:(.+)"/> |
| 80 | + </propertyregex> |
| 81 | + |
| 82 | + <replaceregexp match="@DATE" replace="${date}" file="@{file}" /> |
63 | 83 |
|
64 | 84 | </sequential> |
65 | 85 | </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 | 86 |
|
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> |
100 | | - |
101 | | - <!-- yuicompress: http://www.julienlecomte.net/blog/2007/09/16/ --> |
102 | | - <target name="min.do" depends="source"> |
103 | | - |
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/> |
112 | | - </apply> |
| 87 | + <mkdir dir="${js}"/> |
113 | 88 |
|
114 | | - <replaceregexp match="/\*!" replace="/\*\*" file="${base}.js" /> |
115 | | - <echo message="Minified: ${base}.min.js"/> |
116 | | - |
117 | | - </target> |
118 | | - |
119 | | - |
120 | | - <!-- lint --> |
121 | | - <target name="lint"> |
122 | | - <property name="target" value="lint.do"/> |
123 | | - <antcall target="loop"/> |
| 89 | + <copy todir="${js}"> |
| 90 | + <fileset dir="build/${v.tools}"/> |
| 91 | + </copy> |
| 92 | + |
124 | 93 | </target> |
125 | | - |
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> |
132 | | - </target> |
| 94 | + |
133 | 95 |
|
134 | 96 | </project> |
135 | 97 |
|
|
0 commit comments