js.xml 3.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<project name="Common build file used by JS plugins" default="min">

	<property name="shortname" value="${ant.project.name}"/>

    <condition property="basename" value="${shortname}" else="flowplayer.${shortname}">
        <equals arg1="${shortname}" arg2="flowplayer"/>
    </condition>

	<property name="source.file" value="${basedir}/${basename}.js"/>
    <property name="jar_home" value="../../../flash-build/lib"/>
	<property name="rhino" value="${jar_home}/rhino.jar"/>
	<property name="yui.path" value="${jar_home}/yuicompressor-2.4.2.jar"/>
    <property file="../release/build.properties" />


    <!-- target dir is dynamic -->
17
	<property name="target.dir" value="${basedir}/../../../flash-build/dist"/>
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

	<!-- lint (http://www.jslint.com/lint.html)  -->
   <target name="lint">
		<java jar="${rhino}" fork="true">
			<arg value="${DEVKIT_HOME}/lib/jslint.js" />
			<arg value="${basename}.js" />
		</java>
	</target>


	<!-- copy source file & update tokens -->
	<target name="source">

		<property name="target.file" value="${target.dir}/${basename}-${version}.js"/>
		<copy file="${source.file}" tofile="${target.file}" overwrite="true"/>
		<echo message="${source.file} --> ${target.file} copied" />
		<echo message="${target.file} build" />

	</target>


	<!-- yuicompress: http://www.julienlecomte.net/blog/2007/09/16/ -->
	<target name="min" depends="source">

        <!--<property name="target.file" value="${target.dir}/${basename}-${version}.min.js"/>-->
        <!--<property name="minified.file" value="${target.dir}/${basename}-tmp.min.js"/>-->

        <apply executable="/usr/bin/java" parallel="false">
			<fileset file="${target.file}"/>
            <arg line="-jar"/>
            <arg path="${yui.path}"/>
            <srcfile/>
            <arg line="-o"/>
            <mapper type="glob" from="*.js" to="${target.dir}/*.min.js"/>
            <targetfile/>
        </apply>

		<echo message="${target.file} minified"/>

	</target>

	<!-- for releases.yaml file generation -->
    <target name="write-version">
        <echo message="writing ${basename}: ${version} to ${yaml-file}" />
        <echo file="${yaml-file}" append="true" message="        ${shortname}: ${version}${line.separator}" />
    </target>

    <target name="write-filesize">
        <length property="filesize" file="${target.dir}/${basename}-${version}.js" />
        <echo file="${yaml-file}" append="true" message="    ${basename}.js: ${filesize}${line.separator}" />
    </target>

    <target name="write-dist-info">
71
        <echo file="${dist-file}" append="true" message="${basename}.js:${line.separator}" />
72
73
74
75
76
77
78
79
80
81
82
83
84
85
        <echo file="${dist-file}" append="true" message="    folder: ${basename}${line.separator}" />
        <echo file="${dist-file}" append="true" message="    files:${line.separator}" />
        <echo file="${dist-file}" append="true" message="        - ${basename}-${version}.js${line.separator}" />
        <echo file="${dist-file}" append="true" message="        - ${basename}-${version}.min.js${line.separator}" />
    </target>

    <target name="deploy" if="js.deploy.dir">
        <property name="target.file" value="${target.dir}/${basename}-${version}.min.js"/>
        <echo message="copying ${target.file}" />
        <copy file="${target.file}" todir="${js.deploy.dir}" />
        <copy file="${basedir}/${basename}.js" todir="${js.deploy.dir}" />
    </target>

</project>