blob: 38fd067e854fb0e36a3486d585daae9966124cb0 [file] [log] [blame]
<project name="Create &amp; Update a PhoneGap BlackBerry WebWorks Project or Plugin" default="help">
<!-- LOAD VERSION -->
<loadfile property="version" srcFile="VERSION">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<!-- LOAD PROPERTIES -->
<property name="template.project.dir" location="template/project" />
<property name="template.plugin.dir" location="template/plugin" />
<property name="build.dir" location="build" />
<property name="update.dir" value="lib/phonegap.${version}" />
<property name="jar.src" location="framework/ext/src" />
<property name="jar.path" value="ext" />
<property name="jar.basename" value="phonegap.${version}.jar" />
<property name="jar.file" value="${jar.path}/${jar.basename}" />
<property name="js.src" location="javascript" />
<property name="js.path" value="javascript" />
<property name="js.basename" value="phonegap.${version}.js" />
<property name="js.basename-min" value="phonegap.${version}.min.js" />
<property name="js.file" value="${js.path}/${js.basename}" />
<property name="js.file-min" value="${js.path}/${js.basename-min}" />
<property name="js.license" location="lib/license.js" />
<!-- BUILD JAVASCRIPT -->
<target name="build-javascript">
<mkdir dir="${build.dir}/${js.path}" />
<!-- uncompressed -->
<concat destfile="${build.dir}/${js.file}" append="false">
<fileset dir="${js.src}">
<include name="*.js" />
</fileset>
</concat>
<!-- compressed -->
<compress-js input-file="${build.dir}/${js.file}"
output-file="${build.dir}/${js.file-min}" />
</target>
<!-- BUILD WIDGET EXTENSION -->
<target name="build-extension">
<mkdir dir="${build.dir}/${jar.path}" />
<zip destfile="${build.dir}/${jar.file}">
<fileset dir="${jar.src}" includes="library.xml" />
<fileset dir="${jar.src}" includes="**/*.java" />
</zip>
</target>
<!-- CREATE A PROJECT -->
<target name="create" depends="clean, build-javascript, build-extension">
<fail unless="project.path" message="You must give a project PATH. Use the argument -Dproject.path=&#34;C:\dev\my_project&#34;" />
<available file="${project.path}" property="project.exists" />
<fail if="project.exists" message="The project path must be an empty directory." />
<!-- create project using template directory -->
<mkdir dir="${project.path}" />
<copy todir="${project.path}">
<fileset dir="${template.project.dir}" />
</copy>
<!-- update project files to reference phonegap.x.x.x.js -->
<replaceregexp match="phonegap\.js" replace="${js.basename-min}" byline="true">
<fileset file="${project.path}/www/index.html" />
<fileset file="${project.path}/build.xml" />
</replaceregexp>
<!-- copy phonegap.js -->
<copy todir="${project.path}/www">
<fileset dir="${build.dir}/${js.path}" />
</copy>
<!-- copy ext/ -->
<copy todir="${project.path}/www/ext">
<fileset dir="${build.dir}/${jar.path}" />
</copy>
<!-- save release -->
<mkdir dir="${project.path}/${update.dir}" />
<copy todir="${project.path}/${update.dir}">
<fileset dir="${build.dir}" />
</copy>
<echo>
Project Creation Complete!
==========================
Getting Started:
----------------
cd ${project.path}
ant help
</echo>
</target>
<!-- UPDATE A PROJECT -->
<target name="update" depends="clean, build-javascript, build-extension">
<fail unless="project.path" message="You must give a project PATH. Use the argument -Dproject.path=&#34;C:\dev\my_project&#34;" />
<available file="${project.path}" property="project.exists" />
<fail unless="project.exists" message="The project path cannot be empty." />
<!-- save release -->
<mkdir dir="${project.path}/${update.dir}" />
<copy todir="${project.path}/${update.dir}">
<fileset dir="${build.dir}" />
</copy>
<echo>
Update complete!
================
PhoneGap ${version} has been created.
Update does not alter your project files.
See below for instructions to install PhoneGap ${version}.
Where:
------
${project.path}/${update.dir}
Install:
--------
1. Install the Java Extension:
- delete /www/${jar.path}/phonegap.jar
- copy /${update.dir}/${jar.file}
to /www/${jar.file}
2. Install the JavaScript library:
- delete /www/phonegap.js
- copy /${update.dir}/${js.file}
to /www/${js.basename}
3. Update JavaScript references:
- &#60;script type=&#34;text/javascript&#34; src=&#34;${js.basename}&#34;&#62;&#60;/script&#62;
</echo>
</target>
<!-- CREATE A PLUGIN -->
<target name="create-plugin" depends="">
<!-- validate arguments -->
<fail unless="plugin.path" message="You must give a plugin PATH. Use the argument -Dplugin.path=&#34;C:\dev\my_plugin&#34;" />
<!-- destination must be empty -->
<available file="${plugin.path}" property="plugin.exists" />
<fail if="plugin.exists" message="The plugin path must be an empty directory." />
<!-- copy plugin directory -->
<mkdir dir="${plugin.path}" />
<copy todir="${plugin.path}">
<fileset dir="${template.plugin.dir}" />
</copy>
<echo>
Plugin Creation Complete!
=========================
Getting Started:
----------------
cd ${plugin.path}
ant help
</echo>
</target>
<!-- UPDATE A PLUGIN -->
<target name="update-plugin" depends="">
<fail unless="plugin.path" message="You must give a plugin PATH. Use the argument -Dplugin.path=&#34;C:\dev\my_plugin&#34;" />
<available file="${plugin.path}" property="plugin.exists" />
<fail unless="plugin.exists" message="The plugin path cannot be empty." />
<!-- build.xml -->
<copy todir="${plugin.path}" file="${template.plugin.dir}/build.xml" />
<echo message="Updated build.xml" />
</target>
<!-- CLEAN -->
<target name="clean">
<delete dir="${build.dir}" />
</target>
<!-- HELP -->
<target name="help">
<echo>
NAME
${ant.project.name}
SYNOPSIS
ant COMMAND [-D&lt;argument&gt;=&lt;value&gt;]...
DESCRIPTION
This tool allows you to create and update PhoneGap-BlackBerry-WebWorks projects.
You will want to run update after you have updated the framework source.
In other words, when you &lt;git pull origin master&gt;.
COMMANDS
help ............ Show this help menu.
ant, ant help
create .......... Create a new project
ant create PATH
ant create -Dproject.path="C:\dev\my_project"
update .......... Update an existing project
ant update PATH
ant update -Dproject.path="C:\dev\my_project"
create-plugin ... Create a new plugin
ant create-plugin PATH
ant create-plugin -Dplugin.path="C:\dev\my_plugin"
update-plugin ... Update a plugin's ANT script
ant update-plugin PATH
ant update-plugin -Dplugin.path="C:\dev\my_plugin"
</echo>
</target>
<!-- MACRO: COMPRESS-JS -->
<macrodef name="compress-js">
<attribute name="input-file" />
<attribute name="output-file" />
<sequential>
<property name="output-file.tmp" value="@{output-file}.tmp" />
<!-- compress -->
<java jar="./lib/yuicompressor/yuicompressor-2.4.2.jar"
fork="true"
failonerror="true">
<arg value="--nomunge" />
<arg value="-o"/>
<arg value="${output-file.tmp}" />
<arg value="@{input-file}" />
</java>
<!-- add license to minified file -->
<concat destfile="@{output-file}" append="false">
<fileset file="${js.license}" />
<fileset file="${output-file.tmp}" />
</concat>
<!-- cleanup -->
<delete file="${output-file.tmp}" />
</sequential>
</macrodef>
</project>