My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Examples  
MakeDirDiff can be run as an Ant task and a command line tool
Featured, Phase-Requirements, Phase-Deploy, ant, java, task, dir, files, directory, make, diff, difference, differences, compare, examples
Updated Jun 15, 2010 by igor.kan...@gmail.com

Example of running ‘Make Directory Difference’ tool

Русский: Примеры запуска MakeDirDiff

Defining MakeDirDiff task in Ant script

        <taskdef name="makeDirDiff" classname="org.grenader.makedirdiff.MakeDirDiff">
          <classpath>
            <pathelement location="./ant.jar"/>
            <pathelement location="./jsCssMin-1.0.jar"/>
            <pathelement location="./makeDirDiff-1.4.jar"/>
          </classpath>
        </taskdef>

Executing a sample ANT task

We will run and analyze the sample ant task that is stored in a build.xml file in each makeDirDiff-bin-1.x.zip file.

  1. Download makeDirDiff-bin-1.x.zip file from the Project Download page.
  2. Extract this archive to a directory.
  3. If you wish more details, look into 'build.xml' file to get some information about a way the example Ant task is defined there, otherwise skip this step.
  4. Go to this directory and run an 'ant' command using a system command line interface.
  5. You will see some output and words 'BUILD SUCCESSFUL' at the end. In this case the provided MakeDirDiff example works fine. This example task creates a 'result' directory and copy there all files from 'original' directory. It also stores an 'original' directory content into the 'previous' directory.
  6. Something has gone wrong when you don't see 'BUILD SUCCESSFUL' words. Look at the 'Troubleshooting' chapter here to find out what is your problem.
  7. That’s it! MakeDirDiff made a copy of new/updates files from the ‘original’ directory for you.
  8. Let’s try to make something more difficult. Please, remove the 'result' directory now and run 'ant' command again. You will see that the 'result' directory is created again, but it's empty. This is because it has only new/updated files and directories from the 'original' directory, which have not been changed.
  9. Make a small experiment then. Add some files and directories into the 'original' directory and run the 'ant' command again. The 'result' directory will contain all those new files and directories. It works!

Running as a java application

Command line parameters

MakeDirDiff requires three parameters and optional flags:

  • <original data directory>
  • <result directory>
  • <previous data directory>
optional flags. They can be located in any order in command line and mixed with parameters.
  • -cleanDestDir. Since ver 1.4 This flag makes the application to clean <result directory> at the beginning of work.

Note that MakeDirDiff without parameters or with wrong number of parameters shows this help text.

MS Windows command example

java -cp *; org.grenader.makedirdiff.MakeDirDiff ./original ./result ./previous 

Flag -cleanDestDir can be added to a command line. -cleanDestDir makes the application to clean ./result directory at the beginning of work.

You can find this command in the makeDirDiff-Example.bat in makeDirDiff-bin-1.x.zip archive

Unix command example

java -cp *: org.grenader.makedirdiff.MakeDirDiff ./original ./result ./previous 

Flag -cleanDestDir can be added to a command line. -cleanDestDir makes the application to clean ./result directory at the beginning of work.

You can find this command in the makeDirDiff-Example.sh in makeDirDiff-bin-1.x.zip archive

Example ANT task

The following Ant task is stored in build.xml file in each makeDirDiff-bin-1.x.zip file

 <!--   Basic Example of using makeDirDiff Ant task   -->
    <target name="example">
        <!--  Defind required jars-->
        <path id="taskDependencies">
            <pathelement location="./ant.jar"/>
            <pathelement location="./jsCssMin-1.0.jar"/>
            <pathelement location="./makeDirDiff-1.4.jar"/>
        </path>

        <!--  Defind makeDirDiff Ant task  -->
        <taskdef name="makeDirDiff" classname="org.grenader.makedirdiff.MakeDirDiff">
            <classpath refid="taskDependencies"/>
        </taskdef>

        <!--
        Execute the makeDirDiff task
          "./original" - original data directory. It's defined as a nested fileset item
          "./result" - result directory. It's defined as a destDir attribute
          "./previous" - previous data directory. It's defined as a prevDir attribute
          "cleanDestDir - true/false, not required. If "true" result directory will be                          
                          cleaned before copying new/changed files into it.
        -->
        <makeDirDiff
                destDir="./result"
                prevDir="./previous">
            <fileset dir="./original"/>
        </makeDirDiff>
    </target>

Look at other examples of calling MakeDirDiff from Ant


Sign in to add a comment
Powered by Google Project Hosting