| 1 | <?xml version="1.0"?> |
|---|
| 2 | <!-- ====================================================================== |
|---|
| 3 | Luis Majano |
|---|
| 4 | Mar 16, 2007 5:13:17 PM |
|---|
| 5 | |
|---|
| 6 | coldbox.newapplication |
|---|
| 7 | This task creates a new coldbox application template with your |
|---|
| 8 | application name already configured. |
|---|
| 9 | |
|---|
| 10 | The task will generate a new application template for you in a |
|---|
| 11 | directory of your choice, full path. |
|---|
| 12 | ====================================================================== --> |
|---|
| 13 | <project name="coldbox.newapplication" default="run" basedir="."> |
|---|
| 14 | <!-- Properties --> |
|---|
| 15 | <property file="build.properties"/> |
|---|
| 16 | |
|---|
| 17 | <!-- Load Contrib Tasks --> |
|---|
| 18 | <path id="cp"> |
|---|
| 19 | <fileset dir="../install/antlib"> |
|---|
| 20 | <include name="**/*.jar" /> |
|---|
| 21 | </fileset> |
|---|
| 22 | </path> |
|---|
| 23 | <!-- Define Tasks --> |
|---|
| 24 | <taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="cp" /> |
|---|
| 25 | |
|---|
| 26 | <!-- init --> |
|---|
| 27 | <target name="init" description="Init the generator"> |
|---|
| 28 | <!--Init TimeStamp--> |
|---|
| 29 | <tstamp /> |
|---|
| 30 | <echoproperties regex="gen" /> |
|---|
| 31 | <!-- Input --> |
|---|
| 32 | <input message="Open the SwingGUI Generator or the AntInput Generator. (If you are running this build in Mac OSX from within Eclipse please use AntInput unless running from the command line)" |
|---|
| 33 | addproperty="wizardType" |
|---|
| 34 | validargs="SwingGUI,AntInput" |
|---|
| 35 | defaultvalue="SwingGUI" /> |
|---|
| 36 | <condition property="guiwizard.yes"> |
|---|
| 37 | <equals arg1="${wizardType}" arg2="SwingGUI" /> |
|---|
| 38 | </condition> |
|---|
| 39 | <condition property="guiwizard.no"> |
|---|
| 40 | <equals arg1="${wizardType}" arg2="AntInput" /> |
|---|
| 41 | </condition> |
|---|
| 42 | <condition property="guiwizard.no"> |
|---|
| 43 | <equals arg1="${wizardType}" arg2="" /> |
|---|
| 44 | </condition> |
|---|
| 45 | </target> |
|---|
| 46 | |
|---|
| 47 | <!-- Run this Wizard --> |
|---|
| 48 | <target name="run" description="run the wizard" depends="init,wizard,wizardGUI" /> |
|---|
| 49 | |
|---|
| 50 | <!-- Old School Wizard --> |
|---|
| 51 | <target name="wizard" description="Question Wizard" if="guiwizard.no"> |
|---|
| 52 | <!--Ask for user input to create application--> |
|---|
| 53 | <input message="What is the name of your application: (Ex:blog,forum)?" |
|---|
| 54 | addproperty="app.name"/> |
|---|
| 55 | <!-- Destination --> |
|---|
| 56 | <input message="What is the destination directory: (Ex:/data/webroot)?" |
|---|
| 57 | addproperty="app.destination" /> |
|---|
| 58 | <!-- Use Inheritance --> |
|---|
| 59 | <input message="Use Application.cfc with Inheritance?" validargs="true,false" defaultvalue="true" |
|---|
| 60 | addproperty="app.useInheritance" /> |
|---|
| 61 | <!-- Use Custom Error Template --> |
|---|
| 62 | <input message="Configure the application to use a custom error template (You can skin it afterwards)?" |
|---|
| 63 | validargs="false,true" defaultvalue="false" |
|---|
| 64 | addproperty="app.useErrorTemplate" /> |
|---|
| 65 | <!-- app.favs --> |
|---|
| 66 | <input message="Generate Extra Files (robots.txt,favicon, and more)?" |
|---|
| 67 | validargs="true,false" defaultvalue="true" |
|---|
| 68 | addproperty="app.favs" /> |
|---|
| 69 | <!-- app.rewrite --> |
|---|
| 70 | <input message="Configure your SES Rewrite Engine (If none, /index.cfm/ will be used)?" |
|---|
| 71 | validargs="none,mod_rewrite,isapi" defaultvalue="mod_rewrite" |
|---|
| 72 | addproperty="app.rewrite" /> |
|---|
| 73 | <!-- Unit Tests --> |
|---|
| 74 | <input message="Choose your Unit Testing Engine?" |
|---|
| 75 | validargs="mxunit,cfcunit" defaultvalue="mxunit" |
|---|
| 76 | addproperty="app.unittest" /> |
|---|
| 77 | <!-- Side Bar --> |
|---|
| 78 | <input message="Would you like to configure this application to use the ColdBox SideBar?" |
|---|
| 79 | validargs="true,false" defaultvalue="false" |
|---|
| 80 | addproperty="app.sidebar" /> |
|---|
| 81 | <!-- Run Generation --> |
|---|
| 82 | <antcall target="generate" inheritall="true" inheritrefs="true" /> |
|---|
| 83 | </target> |
|---|
| 84 | |
|---|
| 85 | <!-- Wizard GUI --> |
|---|
| 86 | <target name="wizardGUI" |
|---|
| 87 | description="Create the input forms using AntForm GUI. Quirky in Mac OSX from within Eclipse. Run from the command line." |
|---|
| 88 | if="guiwizard.yes"> |
|---|
| 89 | |
|---|
| 90 | <taskdef name="antform" classname="com.sardak.antform.AntForm" classpathref="cp"/> |
|---|
| 91 | <antform title="ColdBox Application Generator" |
|---|
| 92 | image="../install/Logos-Images-Icons/chat_icon.png" |
|---|
| 93 | width="650" |
|---|
| 94 | height="700" |
|---|
| 95 | lookandfeel="javax.swing.plaf.metal.MetalLookAndFeel" |
|---|
| 96 | icon="../install/Logos-Images-Icons/chat_icon.png"> |
|---|
| 97 | <Controlbar> |
|---|
| 98 | <Button label="Cancel" type="cancel" /> |
|---|
| 99 | <Button label="Reset" type="reset" /> |
|---|
| 100 | <Button label="Generate" type="ok" target="generate" newproject="false" /> |
|---|
| 101 | </Controlbar> |
|---|
| 102 | |
|---|
| 103 | <!--Ask for user input to create application--> |
|---|
| 104 | <textProperty label="Application Name" |
|---|
| 105 | property="app.name" |
|---|
| 106 | columns="25" |
|---|
| 107 | Required="true" |
|---|
| 108 | tooltip="The name of the application to generate" |
|---|
| 109 | focus="true"/> |
|---|
| 110 | <!-- Destination --> |
|---|
| 111 | <fileselectionproperty label="Destination Directory" |
|---|
| 112 | property="app.destination" |
|---|
| 113 | directoryChooser="true" |
|---|
| 114 | Required="true" |
|---|
| 115 | columns="25" |
|---|
| 116 | tooltip="Destination Directory (ex: /data/webroot)"/> |
|---|
| 117 | <!-- Inheritance --> |
|---|
| 118 | <label>Application.cfc with inheritance is the default. If not chosen, then I will build a composition Application.cfc (Inheritance is recommended)</label> |
|---|
| 119 | <radioSelectionProperty label="Application.cfc Inheritance?" |
|---|
| 120 | property="app.useInheritance" |
|---|
| 121 | values="true,false" |
|---|
| 122 | tooltip="Create the application.cfc using inheritance" /> |
|---|
| 123 | <!-- Error Template --> |
|---|
| 124 | <label>Configure the application to use a custom error template. The default is to use the framework's error template.</label> |
|---|
| 125 | <radioSelectionProperty label="Use Custom Error Template?" |
|---|
| 126 | property="app.useErrorTemplate" |
|---|
| 127 | values="false,true" |
|---|
| 128 | tooltip="Configure the application to use a custom error template." /> |
|---|
| 129 | <!-- Favs Template --> |
|---|
| 130 | <label>Generate a robots.txt, favicon and more.</label> |
|---|
| 131 | <radioSelectionProperty label="Generate Extras?" |
|---|
| 132 | property="app.favs" |
|---|
| 133 | values="true,false" |
|---|
| 134 | tooltip="Generate a favicon,robots.txt and more." /> |
|---|
| 135 | <!-- Sidebar Template --> |
|---|
| 136 | <label>Configure your application to use the ColdBox SideBar.</label> |
|---|
| 137 | <radioSelectionProperty label="ColdBox SideBar?" |
|---|
| 138 | property="app.sidebar" |
|---|
| 139 | values="false,true" |
|---|
| 140 | tooltip="Configure the app for the ColdBox SideBar." /> |
|---|
| 141 | <!-- Favs Template --> |
|---|
| 142 | <label>Choose your URL rewrite engine if any. This will create an appropriate .htaccess or isapirewrite.ini file or none and configure your routes.</label> |
|---|
| 143 | <selectionProperty label="URL Rewrite Engine?" |
|---|
| 144 | property="app.rewrite" |
|---|
| 145 | values="mod_rewrite,Isapi,none" |
|---|
| 146 | tooltip="Choose your URL rewrite engine." /> |
|---|
| 147 | <!-- Unit Testing --> |
|---|
| 148 | <selectionProperty label="Unit Testing Engine?" |
|---|
| 149 | property="app.unittest" |
|---|
| 150 | values="mxunit,cfcunit" |
|---|
| 151 | tooltip="Choose your Unit Testing Engine." /> |
|---|
| 152 | |
|---|
| 153 | </antform> |
|---|
| 154 | </target> |
|---|
| 155 | |
|---|
| 156 | <!--Generate--> |
|---|
| 157 | <target name="generate" description="Generate the new skeleton"> |
|---|
| 158 | <echo>Generating new Application: ${app.name}</echo> |
|---|
| 159 | <echo>Destination Directory: ${basedir}/${app.destination}</echo> |
|---|
| 160 | <echo>Generation Date: ${TODAY}</echo> |
|---|
| 161 | |
|---|
| 162 | <!--Generate--> |
|---|
| 163 | <copy todir="${app.destination}/${app.name}"> |
|---|
| 164 | <fileset dir="${src.dir}"> |
|---|
| 165 | <exclude name="${app.destination}" /> |
|---|
| 166 | <exclude name="header.txt" /> |
|---|
| 167 | <exclude name="build.xml" /> |
|---|
| 168 | <exclude name="**/*.xml.cfm" /> |
|---|
| 169 | </fileset> |
|---|
| 170 | </copy> |
|---|
| 171 | <copy todir="${app.destination}/${app.name}"> |
|---|
| 172 | <fileset dir="${src.dir}"> |
|---|
| 173 | <exclude name="${app.destination}" /> |
|---|
| 174 | <exclude name="header.txt" /> |
|---|
| 175 | <exclude name="build.xml" /> |
|---|
| 176 | <include name="**/*.xml.cfm" /> |
|---|
| 177 | </fileset> |
|---|
| 178 | </copy> |
|---|
| 179 | <!--Replace AppName in Config --> |
|---|
| 180 | <replace file="${app.destination}/${app.name}/${base.config}" value="${app.name}" summary="yes"> |
|---|
| 181 | <replacetoken>Your App Name here</replacetoken> |
|---|
| 182 | </replace> |
|---|
| 183 | <!--Replace AppName in eclipse project --> |
|---|
| 184 | <replace file="${app.destination}/${app.name}/.project" value="${app.name}" summary="yes"> |
|---|
| 185 | <replacetoken>@appname@</replacetoken> |
|---|
| 186 | </replace> |
|---|
| 187 | <!--Delete Header Files--> |
|---|
| 188 | <delete file="${app.destination}/${app.name}/build.xml" /> |
|---|
| 189 | <delete file="${app.destination}/${app.name}/build.properties" /> |
|---|
| 190 | <!-- Inheritance If --> |
|---|
| 191 | <if> |
|---|
| 192 | <equals arg1="${app.useInheritance}" arg2="true" casesensitive="false" /> |
|---|
| 193 | <then> |
|---|
| 194 | <delete file="${app.destination}/${app.name}/Application_noinheritance.cfc" /> |
|---|
| 195 | </then> |
|---|
| 196 | <else> |
|---|
| 197 | <delete file="${app.destination}/${app.name}/Application.cfc" /> |
|---|
| 198 | <move file="${app.destination}/${app.name}/Application_noinheritance.cfc" |
|---|
| 199 | tofile="${app.destination}/${app.name}/Application.cfc" /> |
|---|
| 200 | </else> |
|---|
| 201 | </if> |
|---|
| 202 | <!-- Error Template --> |
|---|
| 203 | <if> |
|---|
| 204 | <equals arg1="${app.useErrorTemplate}" arg2="true" casesensitive="false" /> |
|---|
| 205 | <then> |
|---|
| 206 | <replace file="${app.destination}/${app.name}/${base.config}" value="${base.errortemplate}" summary="yes"> |
|---|
| 207 | <replacetoken><![CDATA[<Setting name="CustomErrorTemplate" value="" />]]></replacetoken> |
|---|
| 208 | </replace> |
|---|
| 209 | </then> |
|---|
| 210 | <else> |
|---|
| 211 | <replace file="${app.destination}/${app.name}/${base.config}" value="" summary="yes"> |
|---|
| 212 | <replacetoken>@errortemplate@</replacetoken> |
|---|
| 213 | </replace> |
|---|
| 214 | </else> |
|---|
| 215 | </if> |
|---|
| 216 | <!--Favs --> |
|---|
| 217 | <if> |
|---|
| 218 | <equals arg1="${app.favs}" arg2="false" /> |
|---|
| 219 | <then> |
|---|
| 220 | <delete file="${app.destination}/${app.name}/robots.txt" /> |
|---|
| 221 | <delete file="${app.destination}/${app.name}/favicon.ico" /> |
|---|
| 222 | </then> |
|---|
| 223 | </if> |
|---|
| 224 | <!-- Rewrite Setup --> |
|---|
| 225 | <if> |
|---|
| 226 | <equals arg1="${app.rewrite}" arg2="mod_rewrite" /> |
|---|
| 227 | <then> |
|---|
| 228 | <copy file="${base.htacess}" todir="${app.destination}/${app.name}/" /> |
|---|
| 229 | <antcall target="replaceRewrite" /> |
|---|
| 230 | </then> |
|---|
| 231 | </if> |
|---|
| 232 | <if> |
|---|
| 233 | <equals arg1="${app.rewrite}" arg2="isapi" /> |
|---|
| 234 | <then> |
|---|
| 235 | <copy file="${base.isapi}" todir="${app.destination}/${app.name}/" /> |
|---|
| 236 | <antcall target="replaceRewrite" /> |
|---|
| 237 | </then> |
|---|
| 238 | </if> |
|---|
| 239 | <!-- Unit Testing --> |
|---|
| 240 | <if> |
|---|
| 241 | <equals arg1="${app.unittest}" arg2="mxunit" /> |
|---|
| 242 | <then> |
|---|
| 243 | <delete dir="${app.destination}/${app.name}/test/integration/cfcunit" /> |
|---|
| 244 | <move todir="${app.destination}/${app.name}/test/integration"> |
|---|
| 245 | <fileset dir="${app.destination}/${app.name}/test/integration/mxunit" includes="**/*.cfc" /> |
|---|
| 246 | </move> |
|---|
| 247 | <delete dir="${app.destination}/${app.name}/test/integration/mxunit" /> |
|---|
| 248 | </then> |
|---|
| 249 | <else> |
|---|
| 250 | <delete dir="${app.destination}/${app.name}/test/integration/mxunit" /> |
|---|
| 251 | <move todir="${app.destination}/${app.name}/test/integration"> |
|---|
| 252 | <fileset dir="${app.destination}/${app.name}/test/integration/cfcunit" includes="**/*.cfc" /> |
|---|
| 253 | </move> |
|---|
| 254 | <delete dir="${app.destination}/${app.name}/test/integration/cfcunit" /> |
|---|
| 255 | </else> |
|---|
| 256 | </if> |
|---|
| 257 | <!-- Side Bar--> |
|---|
| 258 | <if> |
|---|
| 259 | <equals arg1="${app.sidebar}" arg2="true" /> |
|---|
| 260 | <then> |
|---|
| 261 | <replace file="${app.destination}/${app.name}/${base.config}" value="${gen.sidebar_setting}" summary="yes"> |
|---|
| 262 | <replacetoken><![CDATA[<!-- @YOURSETTINGS@ -->]]></replacetoken> |
|---|
| 263 | </replace> |
|---|
| 264 | <replace file="${app.destination}/${app.name}/${base.config}" value="${gen.sidebar_interceptor}" summary="yes"> |
|---|
| 265 | <replacetoken><![CDATA[<!-- @SIDEBAR@ -->]]></replacetoken> |
|---|
| 266 | </replace> |
|---|
| 267 | </then> |
|---|
| 268 | <else> |
|---|
| 269 | <replace file="${app.destination}/${app.name}/${base.config}" value="" summary="yes"> |
|---|
| 270 | <replacetoken><![CDATA[<!-- @YOURSETTINGS@ -->]]></replacetoken> |
|---|
| 271 | </replace> |
|---|
| 272 | <replace file="${app.destination}/${app.name}/${base.config}" value="" summary="yes"> |
|---|
| 273 | <replacetoken><![CDATA[<!-- @SIDEBAR@ -->]]></replacetoken> |
|---|
| 274 | </replace> |
|---|
| 275 | </else> |
|---|
| 276 | </if> |
|---|
| 277 | </target> |
|---|
| 278 | |
|---|
| 279 | <!-- Rewrite Engine Setup --> |
|---|
| 280 | <target name="replaceRewrite" description="Replace some rewrite stuff"> |
|---|
| 281 | <replace file="${app.destination}/${app.name}/config/routes.cfm" value="" summary="yes"> |
|---|
| 282 | <replacetoken>/index.cfm</replacetoken> |
|---|
| 283 | </replace> |
|---|
| 284 | </target> |
|---|
| 285 | |
|---|
| 286 | <target name="test"> |
|---|
| 287 | <replace file="config/test.xml" value="${base.errortemplatexml}" summary="yes"> |
|---|
| 288 | <replacetoken><![CDATA[<Setting name="CustomErrorTemplate" value="" />]]></replacetoken> |
|---|
| 289 | </replace> |
|---|
| 290 | </target> |
|---|
| 291 | |
|---|
| 292 | </project> |
|---|