-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.xml
147 lines (123 loc) · 4.79 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?xml version="1.0" encoding="utf-8"?>
<project name="tutorialProject" default="prod" basedir="/Users/addy/buildTut/">
<description>Client-side ANT build file example</description>
<target name="-load.properties"
description="Set properties for this build">
<!--YUI Compressor location-->
<property name="yui.dir" value="${basedir}/yuicompressor/build/yuicompressor-2.4.2.jar"/>
<!--Source JS dir-->
<property name="src.js.dir" value="${basedir}/js"/>
<!--Source CSS dir-->
<property name="src.css.dir" value="${basedir}/css"/>
<!--Source Lint/Hint dir-->
<property name="jslint.js" value="${basedir}/lint/jshint.js"/>
<!--Rhino dir-->
<property name="js.jar" value="${basedir}/lint/rhino/js.jar"/>
<!--Output dir-->
<property name="build.dir" value="build"/>
<!--Build version information -->
<property name="build.major" value="1"/>
<property name="build.minor" value="1"/>
</target>
<!--Create build directories-->
<target name="-init" depends="-load.properties"
description="Create build directory structure">
<!--Create the time stamp for the new build-->
<tstamp>
<format property="TODAY" pattern="EEE, d MMM yyyy HH:mm:ss Z"/>
</tstamp>
<!--Delete previous build files-->
<delete dir="${build.dir}"/>
<!--Recreate the build directories-->
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dir}/js"/>
<mkdir dir="${build.dir}/css"/>
<!--Log the build timestamps to file-->
<echo file="${build.dir}/js/tstamp.txt" append="false">Build Date: ${TODAY}</echo>
<echo file="${build.dir}/css/tstamp.txt" append="false">Build Date: ${TODAY}</echo>
</target>
<!--JS Lint-->
<target depends="-init" name="-js.lint">
<pathconvert pathsep=" " property="jsfiles">
<fileset dir="${build.dir}/js/">
<include name="*.js"/>
</fileset>
</pathconvert>
<exec dir="${build.dir}/js/" executable="java" failonerror="true">
<arg line="-jar ${js.jar} ${jslint.js} ${jsfiles}"/>
</exec>
<echo>Finished</echo>
</target>
<!--Concatenate JS files-->
<target name="-js.concatenate" depends="-js.lint"
description="Concatenates specified JavaScript files">
<concat destfile="${build.dir}/js/concat.js">
<fileset
dir="${src.js.dir}"
includes="*.js"
excludes="first.js, second.js"/>
</concat>
<echo>Finished</echo>
</target>
<!--Concatenate CSS files-->
<target name="-css.concatenate" depends="-init"
description="Concatenates specified CSS files">
<concat destfile="${build.dir}/css/styles.css">
<!--first.css and second.css should be first in the concatenated file-->
<filelist
dir="${src.css.dir}"
files="first.css, second.css"/>
<!--All of the other files in the directory should appear after.-->
<fileset
dir="${src.css.dir}"
includes="*.css"
excludes="first.css, second.css"/>
</concat>
<echo>Finished</echo>
</target>
<!--Minify JS files-->
<target name="-js.minify" depends="-js.concatenate"
description="Minifies JavaScript files">
<apply executable="java" parallel="false" dest="${build.dir}/js">
<fileset
dir="${build.dir}/js"
includes="concat.js"/>
<arg line="-jar"/>
<arg path="${yui.dir}"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="*.js" to="*-min.js"/>
<targetfile/>
</apply>
<echo>Finished</echo>
</target>
<!--Minify CSS files-->
<target name="-css.minify" depends="-css.concatenate"
description="Minifies CSS files">
<apply executable="java" parallel="false" dest="${build.dir}/css">
<fileset
dir="${build.dir}/css"
includes="styles.css"/>
<arg line="-jar"/>
<arg path="${yui.dir}"/>
<arg line="--line-break 0"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="*.css" to="*-min.css"/>
<targetfile/>
</apply>
<echo>Finished</echo>
</target>
<!--Build-->
<target name="prod"
description="Builds project files for production use"
depends="
-load.properties,
-init,
-js.concatenate,
-js.lint,
-css.concatenate,
-js.minify,
-css.minify">
</target>
</project>