forked from asual/jquery-format
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
104 lines (93 loc) · 3.59 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<project name="jQuery Format" default="release" basedir=".">
<property file="build.properties" />
<path id="classpath">
<fileset dir="lib" includes="*.jar" />
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="classpath" />
<target name="release">
<antcall target="dist" />
<antcall target="test" />
<antcall target="bundle" />
</target>
<target name="bundle">
<copy todir="${name}-${version}">
<fileset dir="${dist.dir}">
<include name="**/*" />
</fileset>
<fileset dir="${basedir}">
<include name="${test.dir}/**/*" />
</fileset>
</copy>
<zip destfile="./../${name}-${version}.zip"
basedir="${basedir}"
includes="${name}-${version}/" />
<delete dir="${name}-${version}" />
</target>
<target name="dist">
<mkdir dir="${dist.dir}" />
<echo message="Cleaning dist..." />
<delete includeemptydirs="true">
<fileset dir="${dist.dir}" includes="**/*" />
</delete>
<echo message="Validating files..." />
<antcall target="validate">
<param name="file" value="${src.dir}/${name}" />
</antcall>
<echo message="Copying files..." />
<copy todir="${dist.dir}">
<fileset dir="${src.dir}"/>
</copy>
<echo message="Processing files..." />
<antcall target="process">
<param name="file" value="${dist.dir}/${name}" />
</antcall>
<echo message="Compressing files..." />
<antcall target="compress">
<param name="file" value="${dist.dir}/${name}-${version}.min.js" />
</antcall>
</target>
<target name="validate">
<java classpath="lib/js.jar"
classname="org.mozilla.javascript.tools.shell.Main"
failonerror="true" fork="true">
<arg line="${lib.dir}/rhino.js ${file}.js" />
</java>
</target>
<target name="process">
<tstamp>
<format property="timestamp" pattern="yyyy-MM-dd HH:mm:ss Z (EEE, dd MMM yyyy)" />
</tstamp>
<replaceregexp match="\$\{version\}" file="${file}.js">
<substitution expression="${version}"/>
</replaceregexp>
<replaceregexp match="\$\{timestamp\}" file="${file}.js">
<substitution expression="${timestamp}"/>
</replaceregexp>
<copy file="${file}.js" tofile="${file}-${version}.min.js" />
<move file="${file}.js" tofile="${file}-${version}.js" />
</target>
<target name="compress">
<java jar="${lib.dir}/compiler.jar"
failonerror="true" fork="true">
<arg line="--js=${file} --js_output_file=${file}.tmp" />
</java>
<concat destfile="${file}.lic">
<filelist files="${file}" />
<filterchain>
<headfilter lines="11" />
</filterchain>
</concat>
<concat destfile="${file}">
<filelist files="${file}.lic,${file}.tmp" />
</concat>
<delete>
<filelist files="${file}.lic,${file}.tmp" />
</delete>
</target>
<target name="test">
<delete>
<fileset dir="${test.dir}" includes="${name}-\d.\d+.min.js" />
</delete>
<copy file="${dist.dir}/${name}-${version}.min.js" todir="${test.dir}" overwrite="true" />
</target>
</project>