Ant basics: Copying directories

Thanks to Eclipse making Ant so simple to use I've got it doing a few tasks for me. Well I thought I'd show how simple it is to use. Below is a simple Ant build.xml that I use to copy the ModelGlueAppliactionTemplate files over to a new project. In a nutshell it copies a bunch of files and directories from one location into the location the build.xml was ran from.

view plain print about
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3*
4* Name: is anything you want it to be, for this example its build-mg
5* default: is the first target (method) to run
6* basedir: is the base directory, this can be any local location
7*
8-->

9
10<project name="build-mg" default="deploy" basedir=".">
11
12    
13    <!--
14    *
15    * Description: Describes what the build file does
16    *
17    -->

18    <description>
19 Builds a new ModelGlue project
20 </description>
21
22    
23    <!--
24    *
25    * The property tag is just setting a variable.
26    * name: variable name. You can reference this via ${xxxxx}
27    * value: variable value
28    *
29    -->
    
30 <property name="mgfolder" value="/Path2ModelGlueDirectory/ModelGlue/modelglueapplicationtemplate" />
31
32    
33    <!--
34    *
35    * Target: In effect this is your method
36    * The next set of tags are self explanitory.
37    *    
38    -->

39    <target name="deploy">
40     <copy todir="${basedir}">
41     <fileset dir="${mgfolder}"/>
42     </copy>            
43    </target>
44
45    
46        <!--
47        *
48        * Thats it
49        *
50        -->

51</project>

Posted: 07-Nov-2006

View: 7984

Permalink: here

Comments

Was it you that had an ant script that pulled model-glue from SVN and dispersed it to all the proper directories.. ?

#1 Critter
08/Nov/06 12:54 AM

duh... nevermind.. I see it was reactor..

#2 Critter
08/Nov/06 1:02 AM

I posted (http://www.andyjarrett.co.uk/andy/blog/index.cfm/2...) about Wayne Grahams Model Glue Ant script (http://swem.wm.edu/blogs/waynegraham/index.cfm/200...) which pulls the .zip file down. Thats probably what you meant Critter?

#3 Andy J
08/Nov/06 5:15 AM

Could you please explain us with an better example , like making use of build.xml, build-iml.xml, build.properties.xml, tht would be great , any ways i found an interesting article on how to copy files in ant using scp(http://javamazon.com/2011/11/11/ant-copy-task-scp/...) command with execute it from frm oth eclipse and cmd prompt

#4 javaguru
12/Nov/11 2:29 AM