|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<project name="Cordova"> |
| 3 | + <!-- ////////////// --> |
| 4 | + <!-- Public Targets --> |
| 5 | + <!-- ////////////// --> |
| 6 | + <target name="Sencha + Cordova Build" |
| 7 | + description="Builds into the Cordova general WWW folder" |
| 8 | + depends="cordova-sencha-build"/> |
| 9 | + |
| 10 | + <target name="Sencha + Cordova Prepare" |
| 11 | + description="Builds then prepares application for all platforms" |
| 12 | + depends="cordova-sencha-prepare"/> |
| 13 | + |
| 14 | + <target name="Sencha + Cordova Emulate" |
| 15 | + description="Builds then Emulates in all platforms" |
| 16 | + depends="cordova-sencha-emulate"/> |
| 17 | + |
| 18 | + <target name="Build" |
| 19 | + description="Builds all platforms without building th Sencha App" |
| 20 | + depends="cordova-build"/> |
| 21 | + |
| 22 | + <target name="Prepare" |
| 23 | + description="Prepares all platforms without building the Sencha App" |
| 24 | + depends="cordova-prepare"/> |
| 25 | + |
| 26 | + <target name="Emulate" |
| 27 | + description="Emulates all platforms without building the Sencha App" |
| 28 | + depends="cordova-emulate"/> |
| 29 | + |
| 30 | + <target name="Clean" |
| 31 | + description="Cleans the General Cordova WWW Folder" |
| 32 | + depends="cordova-clean"/> |
| 33 | + |
| 34 | + <!-- Command Line Targets --> |
| 35 | + <target name="cordova-sencha-build" depends="native, build"/> |
| 36 | + <target name="cordova-sencha-emulate" depends="native, -autorun, build"/> |
| 37 | + <target name="cordova-sencha-prepare" depends="package, build, cordova-prepare"/> |
| 38 | + |
| 39 | + <!--Init for All Cordova Task--> |
| 40 | + <target name="-before-cordova-init"/> |
| 41 | + <target name="-cordova-init"> |
| 42 | + <property name="cordova.local.properties" value="${app.dir}/cordova.local.properties"/> |
| 43 | + <property file="${cordova.local.properties}"/> |
| 44 | + </target> |
| 45 | + <target name="-after-cordova-init"/> |
| 46 | + <target name="cordova-init" |
| 47 | + depends="init, -before-cordova-init, -cordova-init, -after-cordova-init"/> |
| 48 | + |
| 49 | + <!-- Cleaning target for the Cordova WWW directory --> |
| 50 | + <target name="-before-cordova-clean"/> |
| 51 | + <target name="-cordova-clean"> |
| 52 | + <delete includeemptydirs="true"> |
| 53 | + <fileset dir="${app.cordova.www.dir}" includes="**/*"/> |
| 54 | + </delete> |
| 55 | + </target> |
| 56 | + <target name="-after-cordova-clean"/> |
| 57 | + <target name="cordova-clean" depends="cordova-init, -before-cordova-clean, -cordova-clean, -after-cordova-clean"/> |
| 58 | + |
| 59 | + <!-- Copies a build folder into the Cordova WWW Folder. Used for Native bulding command --> |
| 60 | + <target name="-before-cordova-copy-build"/> |
| 61 | + <target name="-cordova-copy-build"> |
| 62 | + <if> |
| 63 | + <not> |
| 64 | + <equals arg1="${build.dir}" arg2="${app.cordova.www.dir}"/> |
| 65 | + </not> |
| 66 | + <then> |
| 67 | + <copy todir="${app.cordova.www.dir}" failonerror="false" quiet="true"> |
| 68 | + <fileset dir="${build.dir}"> |
| 69 | + <include name="**/*"/> |
| 70 | + </fileset> |
| 71 | + </copy> |
| 72 | + </then> |
| 73 | + </if> |
| 74 | + </target> |
| 75 | + <target name="-after-cordova-copy-build"/> |
| 76 | + <target name="cordova-copy-build" depends="cordova-init"> |
| 77 | + <x-ant-call unless="skip.cordova-copy-build"> |
| 78 | + <target name="-before-cordova-copy-build"/> |
| 79 | + <target name="-cordova-copy-build"/> |
| 80 | + <target name="-after-cordova-copy-build"/> |
| 81 | + </x-ant-call> |
| 82 | + </target> |
| 83 | + |
| 84 | + <target name="-before-cordova"/> |
| 85 | + <target name="-after-cordova"/> |
| 86 | + |
| 87 | + <!-- Prepares application for all platforms --> |
| 88 | + <target name="-before-cordova-prepare"/> |
| 89 | + <target name="-cordova-prepare"> |
| 90 | + <x-shell reloadprofile="true" dir="${app.cordova.dir}"> |
| 91 | + cordova prepare ${cordova.platforms.clean} |
| 92 | + </x-shell> |
| 93 | + </target> |
| 94 | + <target name="-after-cordova-prepare"/> |
| 95 | + <target name="cordova-prepare" depends="cordova-init, cordova-copy-build, cordova-platform-add"> |
| 96 | + <x-ant-call unless="skip.cordova-prepare"> |
| 97 | + <target name="-before-cordova"/> |
| 98 | + <target name="-before-cordova-prepare"/> |
| 99 | + <target name="-cordova-prepare"/> |
| 100 | + <target name="-after-cordova-prepare"/> |
| 101 | + <target name="-after-cordova"/> |
| 102 | + </x-ant-call> |
| 103 | + </target> |
| 104 | + |
| 105 | + <!-- Emulates application on all platforms --> |
| 106 | + <target name="-before-cordova-emulate"/> |
| 107 | + <target name="-cordova-emulate" if="args.autorun"> |
| 108 | + <x-shell reloadprofile="true" dir="${app.cordova.dir}"> |
| 109 | + cordova emulate ${cordova.platforms.clean} |
| 110 | + </x-shell> |
| 111 | + </target> |
| 112 | + <target name="-after-cordova-emulate"/> |
| 113 | + <target name="cordova-emulate" depends="cordova-init, -autorun, cordova-platform-add, -before-cordova, -before-cordova-emulate, -cordova-emulate, -after-cordova-emulate, -after-cordova"/> |
| 114 | + |
| 115 | + <!-- Builds application for all platforms --> |
| 116 | + <target name="-before-cordova-build"/> |
| 117 | + <target name="-cordova-build"> |
| 118 | + <x-shell reloadprofile="true" dir="${app.cordova.dir}"> |
| 119 | + cordova build ${cordova.platforms.clean} |
| 120 | + </x-shell> |
| 121 | + </target> |
| 122 | + <target name="-after-cordova-build"/> |
| 123 | + <target name="cordova-build" depends="cordova-init, cordova-copy-build, cordova-platform-add, -before-cordova, -before-cordova-build, -cordova-build, -after-cordova-build, -after-cordova"/> |
| 124 | + |
| 125 | + <!-- Adds all missing Platforms from properties file to the project--> |
| 126 | + <target name="-before-cordova-platform-add"/> |
| 127 | + <target name="-cordova-platform-add"> |
| 128 | + <script language="javascript"> |
| 129 | + var platforms = project.getProperty("cordova.platforms"); |
| 130 | + |
| 131 | + if(!platforms) platforms = "" |
| 132 | + platforms = platforms.replace("/all/gi", ""); |
| 133 | + platforms = platforms.replace("/,/g", " "); |
| 134 | + project.setProperty("cordova.platforms.clean", platforms); |
| 135 | + </script> |
| 136 | + |
| 137 | + <x-shell reloadprofile="true" dir="${app.cordova.dir}" outputproperty="cordova.platforms.list"> |
| 138 | + cordova platform list |
| 139 | + </x-shell> |
| 140 | + |
| 141 | + <script language="javascript"> |
| 142 | + var target_platforms = project.getProperty("cordova.platforms.clean").split(" "); |
| 143 | + var existing_platforms = project.getProperty("cordova.platforms.list"); |
| 144 | + var available = existing_platforms.indexOf("Available"); |
| 145 | + if (available >= 0) { |
| 146 | + existing_platforms = existing_platforms.substring(0, available); |
| 147 | + } |
| 148 | + |
| 149 | + var missing_platforms = [], platformIndex, platform; |
| 150 | + for (platformIndex in target_platforms) { |
| 151 | + platform = target_platforms[platformIndex]; |
| 152 | + if(existing_platforms.indexOf(platform) === -1){ |
| 153 | + missing_platforms.push(platform); |
| 154 | + } |
| 155 | + } |
| 156 | + |
| 157 | + if(missing_platforms.length > 0) { |
| 158 | + self.log("Cordova: Missing platforms " + missing_platforms.toString() + ". Attempting add."); |
| 159 | + project.setProperty("cordova.platforms.missing", missing_platforms.join(" ")); |
| 160 | + } else if(existing_platforms.length() >0){ |
| 161 | + self.log("Cordova: All requested platforms exist"); |
| 162 | + } else { |
| 163 | + self.log("Cordova: No platforms exist"); |
| 164 | + } |
| 165 | + </script> |
| 166 | + |
| 167 | + <if> |
| 168 | + <isset property="cordova.platforms.missing"/> |
| 169 | + <then> |
| 170 | + <x-shell reloadprofile="true" dir="${app.cordova.dir}"> |
| 171 | + cordova platform add ${cordova.platforms.missing} |
| 172 | + </x-shell> |
| 173 | + </then> |
| 174 | + </if> |
| 175 | + </target> |
| 176 | + <target name="-after-cordova-platform-add"/> |
| 177 | + <target name="cordova-platform-add" depends="cordova-init, cordova-copy-build,-before-cordova-platform-add, -cordova-platform-add, -after-cordova-platform-add"/> |
| 178 | + |
| 179 | + <target name="-before-native-package"/> |
| 180 | + <target name="-native-package" depends="cordova-init, cordova-copy-build, cordova-platform-add, -before-cordova, -cordova-build, -cordova-emulate, -after-cordova"/> |
| 181 | + <target name="-after-native-package"/> |
| 182 | + |
| 183 | + <!-- Utility Target for specifing autorun --> |
| 184 | + <target name="-autorun"> |
| 185 | + <property name="args.autorun" value="true"/> |
| 186 | + </target> |
| 187 | +</project> |
0 commit comments