blob: dcddbb66e74b0239c792be6db28194a77b33bb31 [file] [log] [blame]
<project name="Create &amp; Update a Cordova BlackBerry WebWorks Project" default="help">
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!-- LOAD VERSION -->
<loadfile property="version" srcFile="VERSION">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<!-- LOAD PROPERTIES -->
<property name="template.project.dir" location="bin/templates/project" />
<property name="template.dist.dir" location="bin/templates/dist" />
<property name="build.dir" location="build" />
<property name="update.dir" value="lib/cordova.${version}" />
<property name="dist.path" location="dist" />
<property name="dist.www.path" location="${dist.path}/www" />
<property name="dist.project.path" location="${dist.path}/sample" />
<property name="jar.src" location="framework/ext/src" />
<property name="jar.path" value="ext" />
<property name="jar.basename" value="cordova.${version}.jar" />
<property name="jar.file" value="${jar.path}/${jar.basename}" />
<property name="playbook.js.path" value="javascript/playbook" />
<property name="playbook.ext.src" location="framework/ext-air" />
<property name="playbook.ext.path" value="ext-air" />
<property name="qnx.js.path" value="javascript/qnx" />
<property name="qnx.ext.src" location="framework/ext-qnx" />
<property name="qnx.ext.path" value="ext-qnx" />
<property name="js.src" location="javascript" />
<property name="js.path" value="javascript" />
<property name="js.basename" value="cordova-${version}.js" />
<property name="js.file" value="${js.path}/${js.basename}" />
<!-- BUILD JAVASCRIPT -->
<target name="build-javascript">
<!-- BB Javascript -->
<mkdir dir="${build.dir}/${js.path}" />
<copy file="${js.src}/cordova.blackberry.js" tofile="${build.dir}/${js.file}" />
</target>
<!-- BUILD BLACKBERRY EXTENSION -->
<target name="build-bb-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>
<!-- BUILD PLAYBOOK EXTENSION -->
<target name="build-pb-extension">
<!-- Copy Ext -->
<mkdir dir="${build.dir}/${playbook.ext.path}" />
<copy todir="${build.dir}/${playbook.ext.path}">
<fileset dir="${playbook.ext.src}" />
</copy>
</target>
<!-- BUILD QNX EXTENSION -->
<target name="build-qnx-extension">
<!-- Copy Ext -->
<mkdir dir="${build.dir}/${qnx.ext.path}" />
<copy todir="${build.dir}/${qnx.ext.path}">
<fileset dir="${qnx.ext.src}" />
</copy>
</target>
<!-- CREATE A PROJECT -->
<target name="create" depends="clean, build-javascript, build-bb-extension, build-pb-extension, build-qnx-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>
<!-- change file permission for cordova scripts because ant copy doesn't preserve file permissions -->
<chmod dir="${project.path}/cordova" perm="700" includes="*"/>
<!-- update project files to reference cordova.x.x.x.js -->
<replaceregexp match="cordova\.js" replace="${js.basename}" byline="true">
<fileset file="${project.path}/www/index.html" />
<fileset file="${project.path}/build.xml" />
</replaceregexp>
<!-- copy cordova.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>
<!-- copy ext-air/ -->
<copy todir="${project.path}/www/ext-air">
<fileset dir="${build.dir}/${playbook.ext.path}" />
</copy>
<!-- copy ext-qnx/ -->
<copy todir="${project.path}/www/ext-qnx">
<fileset dir="${build.dir}/${qnx.ext.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>
<!-- DISTRIBUTION -->
<target name="dist" depends="">
<!-- create a sample project -->
<antcall target="create">
<param name="project.path" value="${dist.project.path}" />
</antcall>
<!-- copy dist template (README.md) -->
<copy todir="${dist.path}">
<fileset dir="${template.dist.dir}" />
</copy>
<!-- change file permission for cordova scripts because ant copy doesn't preserve file permissions -->
<chmod dir="${dist.path}/sample/cordova" perm="700" includes="*" />
<!-- copy cordova.jar -->
<copy todir="${dist.www.path}/ext">
<fileset dir="${build.dir}/${jar.path}" />
</copy>
<!-- copy ext-air/ -->
<copy todir="${dist.www.path}/ext-air">
<fileset dir="${build.dir}/${playbook.ext.path}" />
</copy>
<!-- copy ext-qnx/ -->
<copy todir="${dist.www.path}/ext-qnx">
<fileset dir="${build.dir}/${qnx.ext.path}" />
</copy>
<!-- copy cordova.js -->
<copy todir="${dist.www.path}">
<fileset dir="${build.dir}/${js.path}" />
</copy>
<!-- copy config.xml -->
<copy todir="${dist.www.path}">
<fileset file="${template.project.dir}/www/config.xml" />
</copy>
<!-- copy plugins.xml -->
<copy todir="${dist.www.path}">
<fileset file="${template.project.dir}/www/plugins.xml" />
</copy>
<!-- update config.xml to have a default name-->
<replace file="${dist.project.path}/www/config.xml" token="__NAME__" value="cordovaExample"/>
<replace file="${dist.project.path}/www/config.xml" token="__PACKAGE__" value="org.apache.cordova.example"/>
<echo>
Distribution Complete!
======================
Version:
--------
${version}
Path:
-----
${dist.path}
</echo>
</target>
<target name="version">
<replace dir="." token="${version}" value="${value}" />
<echo>
Version Update Complete!
========================
Version:
--------
Previous: ${version}
Current: ${value}
Remember to:
------------
Review and commit the version update.
$ git diff
$ git commit -am "Update to version ${value}"
$ git tag ${value}
</echo>
</target>
<!-- UPDATE A PROJECT -->
<target name="update" depends="clean, build-javascript, build-bb-extension, build-pb-extension, build-qnx-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!
================
Cordova ${version} has been created.
Update does not alter your project files.
See below for instructions to install Cordova ${version}.
Where:
------
${project.path}/${update.dir}
Install:
--------
1. Install the Java Extension:
- delete /www/${jar.path}/cordova.jar
- copy /${update.dir}/${jar.file}
to /www/${jar.file}
2. Install the JavaScript library:
- delete /www/cordova.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>
<!-- CLEAN -->
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.path}" />
</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 Cordova-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"
dist ............ Create a Cordova distribution build
ant dist
version ......... Update Cordova version
ant version VERSION
ant version -Dvalue="1.0.0"
</echo>
</target>
</project>