| <?xml version="1.0"?> |
| <!-- |
| |
| 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. |
| |
| --> |
| |
| <project name="cordova-app" default="main"> |
| |
| <!-- this ANT script assumes you are in the following directory structure: |
| |
| . /* run ANT here */ |
| ./src/<APP>.mxml /* The main application MXML tag */ |
| ./bin/js-debug /* The result of building APP.mxml via mxmlc |
| ./app/<APP> /* The Cordova application directory |
| |
| 1. This ANT script will build the template Cordova app/APP if it does not |
| already exist. |
| |
| 2. This ANT script will compile the APP.mxml into bin/js-debug |
| |
| 3. This ANT script will remove ./app/<APP>/www contents are replace it with |
| the contents of bin/js-debug. |
| |
| Optionally, you can run the Cordova application using ant run |
| |
| --> |
| |
| <target name="main" depends="create, compilejs, copyfiles" description="Creates the Cordova app if needed, compiles the FlexJS app, copies the results to Cordova app"> |
| </target> |
| |
| <!-- Set up properties and conditions --> |
| |
| <property environment="env"/> |
| |
| <condition property="isWindows" value="windows"> |
| <os family="windows" /> |
| </condition> |
| |
| <condition property="projectdir" value="${user.dir}"> |
| <not> |
| <isset property="projectdir" /> |
| </not> |
| </condition> |
| |
| <!-- override with -Dplatform=other-platform-name --> |
| <condition property="platform" value="android"> |
| <not> |
| <isset property="platform" /> |
| </not> |
| </condition> |
| |
| <!-- override with -Dappname=other-app-name --> |
| <basename property="directory.name" file="${projectdir}" /> |
| <condition property="appname" value="${directory.name}"> |
| <not> |
| <isset property="appname" /> |
| </not> |
| </condition> |
| |
| <condition property="cordova.executable" value="cordova"> |
| <not> |
| <isset property="isWindows" /> |
| </not> |
| </condition> |
| <condition property="cordova.executable" value="cordova.cmd"> |
| <isset property="isWindows" /> |
| </condition> |
| |
| <property name="cordova.target.dir" value="${projectdir}/app/${appname}" /> |
| <available file="${cordova.target.dir}" type="dir" property="app.dir.exists"/> |
| |
| |
| <!-- Create the Cordova template project unless it already exists --> |
| |
| <target name="makedir" unless="app.dir.exists"> |
| <mkdir dir="${projectdir}/app" /> |
| </target> |
| |
| <target name="create" unless="app.dir.exists" depends="makedir" description="Creates the Cordova application template"> |
| <!-- create the project --> |
| <exec executable="${cordova.executable}" dir="${projectdir}/app"> |
| <arg value="create" /> |
| <arg value="${appname}" /> |
| </exec> |
| |
| <echo>Adding in platform(s). This may take awhile.</echo> |
| |
| <!-- add in the platforms --> |
| <exec executable="${cordova.executable}" dir="${cordova.target.dir}"> |
| <arg value="platform" /> |
| <arg value="add" /> |
| <arg value="${platform}" /> |
| </exec> |
| </target> |
| |
| <!-- Compile the FlexJS application --> |
| |
| <target name="compilejs" description="Compiles the FlexJS app into JavaScript"> |
| <echo message="Compiling FlexJS app" /> |
| <exec executable="mxmlc" dir="${projectdir}/src"> |
| <arg value="${appname}.mxml" /> |
| </exec> |
| </target> |
| |
| <!-- Clean www directory --> |
| |
| <target name="purge"> |
| <delete includeEmptyDirs="true"> |
| <fileset dir="${cordova.target.dir}/www" includes="**/*" /> |
| </delete> |
| </target> |
| |
| <!-- Copy files from step above --> |
| |
| <target name="copyfiles" depends="purge"> |
| <echo message="Copying files from project" /> |
| <copy todir="${cordova.target.dir}/www"> |
| <fileset dir="${projectdir}/bin/js-debug" /> |
| </copy> |
| </target> |
| |
| <!-- |
| Running the app on the platform |
| --> |
| |
| <target name="run" description="Runs the Cordova application on the specified platform"> |
| <echo message="Launching ${appname} on platform ${platform}" /> |
| <exec executable="cordova" dir="${cordova.target.dir}"> |
| <arg value="run" /> |
| <arg value="${platform}" /> |
| </exec> |
| </target> |
| |
| <!-- |
| Cleaning Tasks |
| --> |
| |
| <target name="clean" depends="purge" description="Removes files created during the build and copy"> |
| <delete dir="${projectdir}/bin-debug" failonerror="false" /> |
| <delete dir="${projectdir}/bin-release" failonerror="false" /> |
| </target> |
| |
| <target name="super-clean" depends="clean" description="Removes all files and directories except src and its contents"> |
| <delete dir="${projectdir}/bin" /> |
| <delete dir="${projectdir}/app" /> |
| </target> |
| |
| |
| </project> |