[mywebsite.build.xml]
<project name="myWebsite">
<property name="ftp.host" value="ftp.mywebsite.com" />
<property name="ftp.username" value="your-ftp-username" />
<property name="ftp.password" value="your-ftp-password" />
<property name="ftp.folder" value="httpdocs/myproject/" />
<target name="uploadWebsite">
<ftp server="${ftp.host}"
userid="${ftp.username}"
password="${ftp.password}"
remotedir="${ftp.folder}"
>
<fileset dir="c:/xampp/www/myproject">
<exclude name="uploads/**/*.*" />
<exclude name="debug/**/*.*" />
<exclude name="temp/**/*.*" />
</fileset>
</ftp>
</target>
</project>
[uploadWebsite.bat]
c:/Apache-ant/bin/ant.exe -f mywebsite.build.xml uploadWebsite
[myproject.build.properties]
# FTP Settings
ftp.host = ftp.mywebsite.com
ftp.username = your-ftp-username
ftp.password = your-ftp-password
ftp.folder = httpdocs/myproject/
<project name="myWebsite">
<property file="myproject.build.properties" />
.. my targets here ..
</project>
[myproject.build.properties]
# FTP Settings for test
ftp.test.host = ftp.mywebsite.com
ftp.test.username = your-ftp-username
ftp.test.password = your-ftp-password
ftp.test.folder = subdomains/test/httpdocs/myproject/
# FTP Settings for production
ftp.production.host = ftp.mywebsite.com
ftp.production.username = your-ftp-username
ftp.production.password = your-ftp-password
ftp.production.folder = httpdocs/myproject/
<project name="myWebsite">
<property file="myproject.build.properties" />
<target name="uploadWebsiteToTest">
<antcall target="uploadWebsite">
<param name="ftp.host" value="${ftp.test.host}" />
<param name="ftp.username" value="${ftp.test.username}" />
<param name="ftp.password" value="${ftp.test.password}" />
<param name="ftp.folder" value="${ftp.test.folder}" />
</antcall>
</target>
<target name="uploadWebsiteToProduction">
<antcall target="uploadWebsite">
<param name="ftp.host" value="${ftp.production.host}" />
<param name="ftp.username" value="${ftp.production.username}" />
<param name="ftp.password" value="${ftp.production.password}" />
<param name="ftp.folder" value="${ftp.production.folder}" />
</antcall>
</target>
<target name="uploadWebsite">
<ftp server="${ftp.host}"
userid="${ftp.username}"
password="${ftp.password}"
remotedir="${ftp.folder}">
<fileset dir="c:/xampp/www/myproject">
<exclude name="uploads/**/*.*" />
<exclude name="debug/**/*.*" />
<exclude name="temp/**/*.*" />
</fileset>
</ftp>
</target>
</project>
[uploadWebsiteToTest.bat]
c:/Apache-ant/bin/ant.exe -f mywebsite.build.xml uploadWebsiteToTest
[uploadWebsiteToProduction.bat]
c:/Apache-ant/bin/ant.exe -f mywebsite.build.xml uploadWebsiteToProduction
<!-- We need to know where the yuicompressor is located -->
<property name="yui.jar" value="path/to/yuicompressor-2.4.2.jar" />
<!-- @param yui.src The source file
<!-- @param yui.dest The name of the minimized file -->
<!-- @param yui.type Use "css" or "js" -->
<target name="yuicompress">
<java jar="${yui.jar}" fork="true">
<arg value="-v" />
<arg value="-o" />
<arg value="${yui.src}" />
<arg value="--type" />
<arg value="${yui.type}" />
<arg value="--line-break" />
<arg value="60" />
<arg value="${yui.dest}" />
</java>
</target>
<property name="build.dir" value="build" />
<target name="build" depends="clean">
<!-- Make sure the build directory exists -->
<mkdir dir="${build.dir}">
<!-- Copy our files to create a build set -->
<copy todir="${build.dir}">
<fileset dir="c:/xampp/www/myproject">
<exclude name="uploads/**/*.*" />
<exclude name="debug/**/*.*" />
<exclude name="temp/**/*.*" />
<exclude name="build/**/*.*" />
</fileset>
</copy>
<!-- Start optimizing -->
<antcall target="yuicompress">
<param name="yui.src" value="${build.dir}/scripts/main.js" />
<param name="yui.dest" value="${build.dir}/scripts/main.js" />
<param name="yui.type" value="js" />
</antcall>
<antcall target="yuicompress">
<param name="yui.src" value="${build.dir}/css/styles.css" />
<param name="yui.dest" value="${build.dir}/css/styles.css" />
<param name="yui.type" value="css" />
</antcall>
</target>
<!-- An extra target we can use to cleanup before starting a fresh build -->
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="uploadWebsite" depends="build">
<ftp server="${ftp.host}"
userid="${ftp.username}"
password="${ftp.password}"
remotedir="${ftp.folder}">
<fileset dir="${build.dir}" />
</ftp>
</target>
<?php
/* <debug> */
// This code is for development purposes only. Luckely ANT removes it in our build
set_time_limit(0);
ini_set('display_errors','1');
error_reporting(E_ALL);
/* </debug> */
?>
[code]
[code]
<script type="text/javascript">
/* <debug> */
if(typeof console == "undefined") {
alert("Please use firebug. It will make your development life easier");
}
/* </debug> */
?>
</script>
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)