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

Reconcilable Differences

A big problem many developers face is keeping track of custom changes for specific clients. Many of you have installed various CMS packages for people and needed to make small tweaks, whether code or templates or whatever. How do you keep track of those changes in a sane way? This next Ant technique shows how to handle these very situations.



Assume that you've installed the LogiCampus system in the install directory and are doing some work for a particular client. For argument's sake, suppose that this client wants the time and date displayed at the bottom of every page. You can simply update the public_html/index.php page to add this information at the end of the page request.

Think about this a bit more: what are you trying to accomplish? You're trying to determine the differences between this client-specific version and the core package file you started with. If you can determine just those files that have changed, you can import them into CVS on their own without having to import the entire code base. You can then rebuild by simply untarring the original package file and overlaying the changed files from CVS on top of the original files. The following properties and build files illustrate setting up an Ant task to do just this.

install.dir     = install

temp.dir        = temp

package.name    = logicampus-1.1.0

overlay.dir     = overlay
<?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>



        <target name="updateoverlay">

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

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

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

                          compression="gzip"/>

                <copy todir="${overlay.dir}/">

                        <!-- find files in install that have a modified

                                timestamp later than those in overaly -->

                        <fileset dir="${install.dir}">

                                <and>

                                        <different targetdir="${temp.dir}"/>

                                        <type type="file"/>

                                </and>

                        </fileset>

                </copy>

                <delete dir="${temp.dir}"/>

        </target>

</project>

If you remember, I mentioned that you changed the public_html/index.php file in the install directory. Running ant updateoverlay to call the new Ant task, you should get the output:

Buildfile: build.xml



updateoverlay:

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

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

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

     [copy] Copying 1 file to /home/user/overlay

   [delete] Deleting directory /home/user/temp



BUILD SUCCESSFUL

Total time: 5 seconds

If you dig into the overlay directory, you'll find just the one file that you changed (index.php) sitting in the public_html directory. There are no other files or directories copied over into this overlay area--only the differences between the original tar.gz file and the installed version's changes. It's simply a matter of adding or updating these changed files in your overlay directory to CVS or whatever version-control program you use.

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