File: build.xml

package info (click to toggle)
kopano-webapp-plugin-files 2.1.5+dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,540 kB
  • sloc: php: 15,863; xml: 494; java: 295; python: 72; sh: 44; makefile: 11
file content (292 lines) | stat: -rw-r--r-- 9,695 bytes parent folder | download
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<project default="all">
	<property environment="env"/>
	<property name="root-folder" value="${basedir}/../../"/>
	<property name="tools-folder" value="${root-folder}/tools/"/>
	<property name="target-folder" value="${root-folder}/deploy/plugins"/>
	<property name="server-folder" value="${root-folder}/server"/>
	<property name="language-folder" value="${basedir}/language"/>

	<import file="${tools-folder}/antutil.xml"/>

	<typedef file="${tools-folder}/antlib.xml">
		<classpath>
			<pathelement location="${tools-folder}/tools.jar"/>
			<pathelement location="${tools-folder}/lib/compiler.jar"/>
		</classpath>
	</typedef>

	<taskdef resource="net/sf/antcontrib/antcontrib.properties">
		<classpath>
			<pathelement location="${tools-folder}/lib/ant-contrib-1.0b3.jar"/>
		</classpath>
	</taskdef>
		
	<!-- php checks for valitation... -->
	<target name="check-for-php"> 
		<exec executable="php" failonerror="true" failifexecutionfails="false" errorproperty="hasPHP">
			<arg value="-v"/>
		</exec>
	</target> 
	
	<!-- define nicknames for libraries -->
	<property name="yui-compressor" location="${tools-folder}/lib/yuicompressor-2.4.8.jar" />
	<property name="yui-compressor-ant-task" location="${tools-folder}/lib/yui-compressor-ant-task-0.5.jar" />

	<!-- adds libraries to the classpath -->
	<path id="yui.classpath">
		<pathelement location="${yui-compressor}" />
		<pathelement location="${yui-compressor-ant-task}" />
	</path>

	<!-- define tasks -->
	<taskdef name="yui-compressor" classname="net.noha.tools.ant.yuicompressor.tasks.YuiCompressorTask">
		<classpath refid="yui.classpath" />
	</taskdef>

	
	<!-- Determine plugin name -->
	<basename file="${basedir}" property="plugin"/>

	<!-- The Plugin distribution files -->
	<property name="plugin-folder" value="${plugin}"/>
	<property name="plugin-debugfile" value="${plugin}-debug.js"/>
	<property name="plugin-file" value="${plugin}.js"/>

	<!-- The Plugin CSS files -->
	<property name="plugin-css-folder" value="resources/css"/>
	<property name="plugin-css-file" value="${plugin}-min.css"/>
	<property name="plugin-css-debug-file" value="${plugin}.css"/>

	<!-- Meta target -->
	<target name="all" depends="concat, compress"/>

	<!-- Clean -->
	<target name="clean">
		<delete includeemptydirs="true" failonerror="false">
			<!-- Delete the Plugin files -->
			<fileset dir="${target-folder}/${plugin-folder}">
				<include name="**/*"/>
			</fileset>
		</delete>
	</target>

	<!-- Concatenates JavaScript files with automatic dependency generation -->
	<target name="concat">
		<!-- Concatenate plugin JS file -->
		<if>
			<available file="js" type="dir" />
			<then>
				<mkdir dir="${target-folder}/${plugin-folder}/js"/>
				<echo message="Concatenating: ${plugin-debugfile}"/>
				<zConcat outputFolder="${target-folder}/${plugin-folder}/js" outputFile="${plugin-debugfile}" prioritize="\w+">
					<concatfiles>
						<fileset dir="js" includes="**/*.js" excludes="external/*.js"/>
					</concatfiles>
				</zConcat>
			</then>
		</if>

		<!-- Concatenate plugin CSS files -->
		<if>
			<available file="${plugin-css-folder}" type="dir" />
			<then>
				<mkdir dir="${target-folder}/${plugin-folder}/${plugin-css-folder}"/>
				<echo message="Concatenating: ${plugin-css-debug-file}"/>
				<!--zConcat outputFolder="${target-folder}/${plugin-folder}/${plugin-css-folder}" outputFile="${plugin-css-debug-file}">
					<concatfiles>
						<fileset dir="${plugin-css-folder}" includes="**/*.css" />
					</concatfiles>
				</zConcat-->
				<concat destfile="${target-folder}/${plugin-folder}/${plugin-css-folder}/${plugin-css-debug-file}">
					<fileset dir="${plugin-css-folder}" includes="**/*.css" />
				</concat>
			</then>
		</if>
	</target>

	<!-- Compress JavaScript -->
	<target name="compress">
		<if>
			<available file="${target-folder}/${plugin-folder}/js/${plugin-debugfile}" type="file" />
			<then>
				<echo message="Compiling: ${plugin-debugfile}" />
				<zCompile inputFolder="${target-folder}/${plugin-folder}/js" inputFile="${plugin-debugfile}" outputFolder="${target-folder}/${plugin-folder}/js" outputFile="${plugin-file}">
					<externs>
						var Ext = {};
						var Zarafa = {};
						var container = {};
						var console = {};
						var odf = {};
						var PDFJS = {};
						var _ = function(key, domain) {};
						var dgettext = function(domain, msgid) {};
						var dngettext = function(domain, msgid, msgid_plural, count) {};
						var dnpgettext = function(domain, msgctxt, msgid, msgid_plural, count) {};
						var dpgettext = function(domain, msgctxt, msgid) {};
						var ngettext = function(msgid, msgid_plural, count) {};
						var npgettext = function(msgctxt, msgid, msgid_plural, count) {};
						var pgettext = function(msgctxt, msgid) {};
					</externs>
				</zCompile>
			</then>
		</if>
	</target>

	<!-- syntax check all PHP files -->
	<target name="validate" if="hasPHP" depends="check-for-php, predeploy">
		<if>
			<available filepath="${target-folder}/${plugin-folder}/" file="config.php" type="file" />
			<then>
				<antcall target="syntax-check">
					<param name="file" value="${target-folder}/${plugin-folder}/config.php"/>
				</antcall>
			</then>
			<else>
				<echo message="config.php does not exist" />
			</else>
		</if>
		<if>
			<available filepath="${target-folder}/${plugin-folder}/" file="php" type="dir" />
			<then>
				<foreach target="syntax-check" param="file" parallel="true">
					<path>
						<fileset dir="${target-folder}/${plugin-folder}/">
							<include name="**/*.php"/>
						</fileset>
					</path>
				</foreach>
			</then>
			<else>
				<echo message="Directory ${target-folder}/${plugin-folder}/php does not exist" />
			</else>
		</if>
	</target>

	<target name="syntax-check">
		<echo message="validating ${file}"/>
		<exec executable="php" failonerror="true" failifexecutionfails="false">
			<arg value="-l"/>
			<arg value="${file}"/>
		</exec>
	</target>
	
	<!-- Generate language files -->
	<target name="language">
		<if>
			<available file="msgfmt" filepath="${env.PATH}" />
			<then>
				<foreach target="msgfmt" param="file">
					<path>
						<fileset dir="${language-folder}">
							<include name="**/LC_MESSAGES/*.po"/>
						</fileset>
					</path>
				</foreach>
			</then>
			<else>
				<echo message="WARNING: msgfmt not available, not generating *.mo files for translations"/>
				<!-- just copy files -->
				<copy todir="${target-folder}/${plugin-folder}">
					<fileset dir=".">
						<include name="language/**/*.mo"/>
						<include name="language/**/*.txt"/>
					</fileset>
				</copy>
			</else>
		</if>
	</target>

	<target name="msgfmt">
		<propertyregex property="outfile" input="${file}" regexp=".*\/(language\/.*)\.po" replace="${target-folder}/${plugin-folder}/\1\.mo"/>
		<echo message="Converting ${file} to ${outfile}"/>
		<dirname property="outdir" file="${outfile}"/>
		<mkdir dir="${outdir}"/>
		<exec executable="msgfmt" failonerror="true" logError="true">
			<arg value="-c"/>
			<arg value="-v"/>
			<arg value="-o"/>
			<arg value="${outfile}"/>
			<arg value="${file}"/>
		</exec>
	</target>
			
	<!-- Precopy some files and make replacements - needed for validating -->
	<target name="predeploy" depends="clean">
		<mkdir dir="${target-folder}/${plugin-folder}"/>
		
		<!-- copy files -->
		<copy todir="${target-folder}/${plugin-folder}">
			<fileset dir=".">
				<include name="php/**/*.php"/>
				<include name="php/.htaccess"/>
				<include name="config.php"/>
			</fileset>
		</copy>
	</target>
	
	<!-- Install all files into the target folder -->
	<target name="deploy" depends="clean, compress, compresscss, validate, language">

		<!-- Copy (and validate) manifest.xml -->
		<if>
			<available file="xmllint" filepath="${env.PATH}" />
			<then>
				<exec executable="xmllint" output="${target-folder}/${plugin-folder}/manifest.xml" failonerror="true" logError="true">
					<arg value="--valid"/>
					<arg value="--path"/>
					<arg value="${server-folder}"/>
					<arg value="manifest.xml"/>
				</exec>
			</then>
			<else>
				<echo message="WARNING: xmllint not available, not performing syntax-check on manifest.xml"/>
				<!-- xmllint is not available, so we must copy the file manually -->
				<copy todir="${target-folder}/${plugin-folder}">
					<fileset dir=".">
						<include name="manifest.xml"/>
					</fileset>
				</copy>
			</else>
		</if>

		<!-- copy files -->
		<copy todir="${target-folder}/${plugin-folder}">
			<fileset dir=".">
				<include name="resources/**/*.*"/>
				<include name="js/external/*.*"/>
				<include name="CHANGELOG.txt"/>
				<include name="php/Files/Backend/**/*.css"/>
				<include name="php/Files/Backend/**/*.js"/>
				<!-- exclude the ant script -->
				<exclude name="build.xml"/>
				<!-- CSS is generated during build -->
				<exclude name="resources/css/*.*"/>
				<!-- gimp raw files -->
				<exclude name="resources/**/*.xcf"/>
			</fileset>
		</copy>
	</target>
	
	<!-- compresses each CSS file -->
	<target name="compresscss" depends="concat">
	
		<available file="${tools-folder}/lib/yui-compressor-ant-task-0.5.jar" property="YUIANT_AVAILABLE" />
		<fail unless="YUIANT_AVAILABLE" message="yui-compressor-ant-task-0.5.jar not found" />
		
		<if>
			<available file="${target-folder}/${plugin-folder}/${plugin-css-folder}/${plugin-css-debug-file}" type="file" />
			<then>
				<yui-compressor 
					warn="false" 
					munge="true" 
					preserveallsemicolons="false" 
					fromdir="${target-folder}/${plugin-folder}/${plugin-css-folder}" 
					todir="${target-folder}/${plugin-folder}/${plugin-css-folder}">

				  <include name="${plugin-css-debug-file}" />
				</yui-compressor>
			</then>
		</if>
	</target>

</project>