Now: Tutorial for Web and Software Design > PHP > PHP Basic > PHP Content
> Improve Your Build Process with Ant [Bookmark it]
Improve Your Build Process with Ant

Improve Your Build Process with Ant

Building from a Basic Package

Here's another interesting thing Ant can provide--tar and gzip features. tar, short for "tape archive," is a standard way of packaging groups of files for later untarring. gzip is a GNU utility that compresses a file. Many others distribute much software, including PHP itself, as .tar.gz--gzipped tar--files.



Nothing shows this off as well as a real-life example of using Ant to install a tar.gz file. For this example, I'll use the LogiCampus project. Using this build.xml file:

<?xml version="1.0"?>

<project name="Sample Project" default="init" basedir=".">



        <description>Example project</description>



        <target name="init">

                <mkdir dir="install"/>

                <!-- don't forget the compression attr -->

                <untar src="logicampus-1.1.0.tar.gz" dest="install"

                          compression="gzip"/>

        </target>

</project>

and running ant I get the output:

Buildfile: build.xml



init:

    [mkdir] Created dir: /home/user/install

    [untar] Expanding: /home/user/logicampus-1.1.0.tar.gz into

        /home/user/install



BUILD SUCCESSFUL

Total time: 1 second

The above file told Ant to make a directory called install and unpack the original LogiCampus project into that directory.

I'm hoping that you can already see the need for the variables introduced in the first example. Ant also provides a simple way of including files that contain your variables. Ant refers to these variables as properties and uses the property tag to include these files.

Consider now two files, config.properties and build.xml, respectively:

#########################################################

install.dir  = install

temp.dir     = temp

package.name = logicampus-1.1.0

#########################################################
<?xml version="1.0"?>

<project name="Sample Project" default="init" basedir=".">



        <description>Example project</description>



        <property file="config.properties"/>



        <target name="init">

                <mkdir dir="${install.dir}"/>

                <!-- don't forget the compression attr -->

                <untar src="${package.name}.tar.gz" dest="${install.dir}"

                          compression="gzip"/>

        </target>

</project>

Notice the separation of the installation directory and package name into the properties file. As you do more configuration with Ant, keep your configurations in a separate file. So far, this is fairly basic, admittedly. This is just a small script that will untar a file into a directory.

Prev  [1] [2] [3] [4] Next

[Bookmark][Print] [Close][To Top]
  • Prev Article-PHP:

  • Next Article-PHP:
  • Related Materias
    Important Notice for Apach
    Custom-Compiling Apache an
    Simplify Your Life with Ap
    Industrial-Strength Webcas
    Monitoring Apache Page-Loa
    Implementing MVC in PHP: T
    Implementing MVC in PHP: T
    Simplify PHP Development w
    Implementing MVC in PHP: T
    Important Notice for PHP D
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial