Apache Ant Tasks – JAR ”; Previous Next Description Jar task jars a set of file. Properties Sr.No Attributes & Description 1 Destfile The JAR file to create. 2 Basedir The directory from which to jar the files. 3 Compress Not only store data but also compress them. Unless you set the keepcompression attribute to false, this will apply to the entire archive, not only the files you”ve added while updating. 4 Keepcompression For entries coming from existing archives (like nested zipfilesets or while updating the archive), keep the compression as it has been originally instead of using the compress attribute. 5 Encoding The character encoding to use for filenames inside the archive. 6 Filesonly Store only file entries. 7 Include comma- or space-separated list of patterns of files that must be included. 8 Includesfile Name of a file. Each line of this file is taken to be an include pattern. 9 Excludes comma- or space-separated list of patterns of files that must be excluded. 10 Excludesfile Name of a file. Each line of this file is taken to be an exclude pattern. 11 Defaultexcludes Indicates whether default excludes should be used or not (yes|no). 12 Menifest The manifest file to use. 13 Filesetmanifest Behavior when a manifest file is found in a zipfileset or zipgroupfileset file. Valid values are skip, merge, and mergewithoutmain. merge will merge all of the manifests together, and merge this into any other specified manifests. mergewithoutmain merges everything but the Main section of the manifests. 14 Whenmanifestonly Behavior when no files match. Valid values are fail, skip, and create. 15 Manifestencoding The encoding used to read the JAR manifest, when a manifest file is specified. 16 Index Whether to create an index list to speed up classloading. Unless you specify additional jars with nested indexjars elements, only the contents of this jar will be included in the index. 17 indexMetaInf Whether to include META-INF and its children in the index. Doesn”t have any effect if index is false. Oracle”s jar implementation used to skip the META-INF directory and Ant followed that example. The behavior has been changed with Java 5. In order to avoid problems with Ant generated jars on Java 1.4 or earlier, Ant will not include META-INF unless explicitly asked to. 18 Manifestencoding The encoding used to read the JAR manifest, when a manifest file is specified. 19 Update Indicates whether to update or overwrite the destination file if it already exists. 20 Duplicate Behavior when a duplicate file is found. Valid values are add, preserve, and fail. 21 Roundup Whether the file modification times will be rounded up to the next even number of seconds. 22 Level Non-default level at which file compression should be performed. Valid values range from 0 (no compression/fastest) to 9 (maximum compression/slowest). 23 preserve0permissions When updating an archive or adding entries from a different archive Ant will assume that a Unix permissions value of 0 (nobody is allowed to do anything to the file/directory) means that the permissions haven”t been stored at all rather than real permissions and will instead apply its own default values. 24 useLanguageEncodingFlag Whether to set the language encoding flag if the encoding is UTF-8. This setting doesn”t have any effect if the encoding is not UTF-8. 25 createUnicodeExtraFields Whether to create Unicode extra fields to store the file names a second time inside the entry”s metadata. 26 fallbacktoUTF8 Whether to use UTF-8 and the language encoding flag instead of the specified encoding if a file name cannot be encoded using the specified encoding. 27 mergeClassPathAttributes Whether to merge the Class-Path attributes found in different manifests (if merging manifests). If false, only the attribute of the last merged manifest will be preserved. 28 flattenAttributes Whether to merge attributes occurring more than once in a section (this can only happen for the Class-Path attribute) into a single attribute. 29 zip64Mode When to use Zip64 extensions for entries. The possible values are never, always and as-needed. Example Usage Create build.xml with the following content − <?xml version=”1.0″?> <project name=”TutorialPoint” default=”info”> <target name=”info”> <jar basedir=”app” destfile=”app.jar” /> <echo>jar created.</echo> </target> </project> Above script will create an ear file in the current directory as myapp.ear. Output Running Ant on the above build file produces the following output − F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml info: [jar] Building jar: F:tutorialspointantapp.jar [echo] jar created. BUILD SUCCESSFUL Total time: 0 seconds Print Page Previous Next Advertisements ”;
Category: apache Ant Tasks
ANT Tasks – Java
Apache Ant Tasks – Java ”; Previous Next Description Java task executes a Java class within the running JVM or forks another JVM if specified using fork=true; Properties Sr.No Attributes & Description 1 Classname The Java class to execute. 2 Jar The location of the jar file to execute. fork must be set to true if this option is selected. 3 Module The initial or main module to resolve (must have a Main-Class entry in the manifest). fork must be set to true if this option is selected. 4 Sourcefile The location of a “.java” file or a file containing shebang with Java source code. Set this attribute to run Java single file source programs, a feature introduced in Java 11. fork must be set to true if this option is selected. 5 Classpath The classpath to use. 6 Classpathref The classpath to use, given as reference to a Path defined elsewhere. 7 Modulepath Specify where to find application modules. A list of directories of modules, module files or exploded modules. 8 modulepathref The modulepath to use, given as reference to a Path defined elsewhere. 9 Fork If enabled triggers the class execution in another JVM. 10 Spawn If enabled allows to start a process which will outlive Ant. Requires that fork is true, and not compatible with timeout, input, output, error, result attributes 11 Sourcefile The location of a “.java” file or a file containing shebang with Java source code. Set this attribute to run Java single file source programs, a feature introduced in Java 11. fork must be set to true if this option is selected. 12 jvm The command used to invoke JVM. The command is resolved by java.lang.Runtime.exec(). Ignored if fork is false. 13 Maxmemory Max amount of memory to allocate to the forked JVM, ignored if fork is false. 14 Failonerror Stop the build process if the command exits with a return code other than 0. 15 resultproperty The name of a property in which the return code of the command should be stored. Only of interest if failonerror is false and if fork is true. 16 DIR The directory to invoke the JVM in, ignored if fork is false. 17 Output Name of a file to which to write the output. If the error stream is not also redirected to a file or property, it will appear in this output. 18 Error The file to which the standard error of the command should be redirected. 19 logerror This attribute is used when you wish to see error output in Ant”s log and you are redirecting output to a file/property. The error output will not be included in the output file/property. If you redirect error with the error or errorProperty attributes, this will have no effect. 20 Append Whether output and error files should be appended to or overwritten. 21 Outputproperty The name of a property in which the output of the command should be stored. Unless the error stream is redirected to a separate file or stream, this property will include the error output. 22 Errorproperty The name of a property in which the standard error of the command should be stored. 23 Input A file from which the executed command”s standard input is taken. This attribute is mutually exclusive with the input string attribute. 24 Inputstring A string which serves as the input stream for the executed command. This attribute is mutually exclusive with the input attribute. 25 Newenvironment Do not propagate old environment when new environment variables are specified. 26 Timeout Stop the command if it doesn”t finish within the specified time (given in milliseconds). It is highly recommended to use this feature only if fork is true. 27 Clonevm If set to true, then all system properties and the bootclasspath of the forked JVM will be the same as those of the JVM running Ant. 28 Discardoutput Whether output should completely be discarded. This setting is incompatible with any setting that redirects output to files or properties. If you set this to true error output will be discared as well unless you redirect error output to files, properties or enable logError. 29 Discarderror Whether error output should completely be discarded. This setting is incompatible with any setting that redirects error output to files or properties as well as logError. Example Usage Create TestMessage.java with the following content − public class TestMessage { public static void main(String[] args) { System.out.println(“Welcome to tutorialspoint.com”); } } Create build.xml with the following content − <?xml version=”1.0″?> <project name=”TutorialPoint” default=”info”> <target name=”info”> <java classname=”TestMessage” classpath=”.”/> </target> </project> Above script will run a java class file to print output. Output Running Ant on the above build file produces the following output − F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml info: [java] Welcome to tutorialspoint.com BUILD SUCCESSFUL Total time: 0 seconds Print Page Previous Next Advertisements ”;
ANT Tasks – Length
Apache Ant Tasks – Length ”; Previous Next Description Length task display or set a property containing length information for a string, a file, or one or more nested resource collections. It can also be used as a condition. Properties Sr.No Attributes & Description 1 Property The property to set. 2 Mode File length mode; when all the resulting value is the sum of all included resources” lengths; when each the task outputs the absolute path and length of each included resource, one per line. 3 File Single file whose length to report. 4 Resource Single resource whose length to report (using extended properties handling). 5 String The string whose length to report. 6 Trim Whether to trim when operating on a string. 7 Length Comparison length. 8 When Comparison type: equal, eq, greater, gt, less, lt, ge (greater or equal), ne (not equal), le (less or equal). Example Usage Create build.xml with the following content − <?xml version=”1.0″?> <project name=”TutorialPoint” default=”info”> <length string=”tutorialspoint” property=”text.size”/> <target name=”info”> <echo message=”${text.size}”/> </target> </project> Output Running Ant on the above build file produces the following output − F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml info: [echo] 14 BUILD SUCCESSFUL Total time: 0 seconds Print Page Previous Next Advertisements ”;
Ant Tasks – Discussion
Discuss Apache Ant Tasks ”; Previous Next Apache ANT is a Java based build tool from Apache Software Foundation. Apache ANT’s build files are written in XML and they take advantage of being open standard, portable and easy to understand. This tutorial will teach you how to use Apache ANT to automate the build and deployment process in simple and easy steps. After completing this tutorial, you will find yourself at a moderate level of expertise in using Apache ANT from where, you can take yourself to next levels. Print Page Previous Next Advertisements ”;
ANT Tasks – MkDir
Apache Ant Tasks – MkDir ”; Previous Next Description Mkdir task creates a directory. Also non-existent parent directories are created, when necessary. Does nothing if the directory already exists. Properties Sr.No Attributes & Description 1 DIR The directory to create. Example Usage Create build.xml with the following content − <?xml version=”1.0″?> <project name=”TutorialPoint” default=”info”> <mkdir dir=”dist”/> <target name=”info”> </target> </project> Output Running Ant on the above build file produces the following output − F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml [mkdir] Created dir: F:tutorialspointantdist info: BUILD SUCCESSFUL Total time: 0 seconds Print Page Previous Next Advertisements ”;
ANT Tasks – WAR
Apache Ant Tasks – WAR ”; Previous Next Description War task is an extension of the Jar task with special treatment for files that should end up in the WEB-INF/lib, WEB-INF/classes or WEB-INF directories of the Web Application Archive. Properties Sr.No Attributes & Description 1 Destfile The WAR file to create. 2 Webxml The servlet configuration descriptor to use (WEB-INF/web.xml). 3 Basedir The directory from which to jar the files. 4 Compress Not only store data but also compress them. Unless you set the keepcompression attribute to false, this will apply to the entire archive, not only the files you”ve added while updating. 5 Keepcompression For entries coming from existing archives (like nested zipfilesets or while updating the archive), keep the compression as it has been originally instead of using the compress attribute. 6 Encoding The character encoding to use for filenames inside the archive. 7 Filesonly Store only file entries. 8 Include comma- or space-separated list of patterns of files that must be included. 9 includesfile Name of a file. Each line of this file is taken to be an include pattern. 10 Excludes comma- or space-separated list of patterns of files that must be excluded. 11 Excludesfile Name of a file. Each line of this file is taken to be an exclude pattern. 12 defaultexcludes Indicates whether default excludes should be used or not (yes|no). 13 Menifest The manifest file to use. 14 Filesetmanifest Behavior when a manifest file is found in a zipfileset or zipgroupfileset file. Valid values are skip, merge, and mergewithoutmain. merge will merge all of the manifests together, and merge this into any other specified manifests. mergewithoutmain merges everything but the Main section of the manifests. 15 Whenmanifestonly Behavior when no files match. Valid values are fail, skip, and create. 16 Manifestencoding The encoding used to read the JAR manifest, when a manifest file is specified. 17 Index Whether to create an index list to speed up classloading. Unless you specify additional jars with nested indexjars elements, only the contents of this jar will be included in the index. 18 indexMetaInf Whether to include META-INF and its children in the index. Doesn”t have any effect if index is false. Oracle”s jar implementation used to skip the META-INF directory and Ant followed that example. The behavior has been changed with Java 5. In order to avoid problems with Ant generated jars on Java 1.4 or earlier, Ant will not include META-INF unless explicitly asked to. 19 Manifestencoding The encoding used to read the JAR manifest, when a manifest file is specified. 20 Update Indicates whether to update or overwrite the destination file if it already exists. 21 Duplicate Behavior when a duplicate file is found. Valid values are add, preserve, and fail. 22 Roundup Whether the file modification times will be rounded up to the next even number of seconds. 23 Level Non-default level at which file compression should be performed. Valid values range from 0 (no compression/fastest) to 9 (maximum compression/slowest). 24 preserve0permissions When updating an archive or adding entries from a different archive Ant will assume that a Unix permissions value of 0 (nobody is allowed to do anything to the file/directory) means that the permissions haven”t been stored at all rather than real permissions and will instead apply its own default values. 25 useLanguageEncodingFlag Whether to set the language encoding flag if the encoding is UTF-8. This setting doesn”t have any effect if the encoding is not UTF-8. 26 createUnicodeExtraFields Whether to create Unicode extra fields to store the file names a second time inside the entry”s metadata. 27 fallbacktoUTF8 Whether to use UTF-8 and the language encoding flag instead of the specified encoding if a file name cannot be encoded using the specified encoding. 28 mergeClassPathAttributes Whether to merge the Class-Path attributes found in different manifests (if merging manifests). If false, only the attribute of the last merged manifest will be preserved. 29 FlattenAttributes Whether to merge attributes occurring more than once in a section (this can only happen for the Class-Path attribute) into a single attribute. 30 zip64Mode When to use Zip64 extensions for entries. The possible values are never, always and as-needed. 31 Needxmlfile Flag to indicate whether or not the web.xml file is needed. It should be set to false when generating servlet 2.5+ WAR files without a web.xml file. Example Usage Create build.xml with the following content − <?xml version=”1.0″?> <project name=”TutorialPoint” default=”info”> <target name=”info”> <war destfile=”myapp.war” webxml=”web.xml”></war> </target> </project> Above script will create an ear file in the current directory as myapp.ear. Output Running Ant on the above build file produces the following output − F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml info: [war] Building war: F:tutorialspointantmyapp.war BUILD SUCCESSFUL Total time: 1 second Print Page Previous Next Advertisements ”;
Ant Tasks – Quick Guide
Apache Ant Tasks – Quick Guide ”; Previous Next Apache Ant Tasks – Introduction ANT stands for Another Neat Tool. It is a Java-based build tool from computer software development company Apache. Before going into the details of Apache Ant, let us first understand why we need a build tool. Need for a Build Tool On an average, a developer spends a substantial amount of time doing mundane tasks like build and deployment that include − Compiling the code Packaging the binaries Deploying the binaries to the test server Testing the changes Copying the code from one location to another To automate and simplify the above tasks, Apache Ant is useful. It is an Operating System build and deployment tool that can be executed from the command line. Ant tasks simplifies executions of operations. History of Apache Ant Ant was created by software developer James Duncan Davidson who is also the original creator of webserver application Tomcat. Ant was originally used to build Tomcat, and was bundled as a part of Tomcat distribution. It was born out of the problems and complexities associated with the Apache Make tool. It was promoted as an independent project in Apache in the year 2000. The latest version of Apache Ant as on October 2021 is 1.10.12. Features of Apache Ant The features of Apache Ant are listed below − It is the most complete Java build and deployment tool available. It is platform neutral and can handle platform specific properties, such as file separators. It can be used to perform platform specific tasks such as modifying the modified time of a file using ”touch” command. Ant scripts are written using plain XML. If you are already familiar with XML, you can learn Ant pretty quickly. Ant is good at automating complicated repetitive tasks. Ant comes with a big list of predefined tasks. Ant provides an interface to develop custom tasks. Ant can be easily invoked from the command line and it can integrate with free and commercial IDEs. Apache Ant Tasks – Environment Setup Apache Ant is distributed under the Apache Software License which is a fully-fledged open source license certified by the open source initiative. The latest Apache Ant version, including its full-source code, class files, and documentation can be found at https://ant.apache.org. Installing Apache Ant It is assumed that you have already downloaded and installed Java Development Kit (JDK) on your computer. If not, please follow the instructions available at file:///C:/java/java_environment_setup.htm Ensure that the JAVA_HOME environment variable is set to the folder, where your JDK is installed. Download the binaries from https://ant.apache.org Unzip the zip file to a convenient location c:folder by using Winzip, winRAR, 7-zip or similar tools. Create a new environment variable called ANT_HOME that points to the Ant installation folder. In this case, it is c:apache-ant-1.10.12-bin folder. Append the path to the Apache Ant batch file to the PATH environment variable. In our case, this would be the c:apache-ant-1.10.12-binbin folder. Verifying the Installation To verify the successful installation of Apache Ant on your computer, type ant on your command prompt. You should see an output as given below − C:>ant -version Apache Ant(TM) version 1.10.12 compiled on October 13 2021 If you do not see the above output, then please verify that you have followed the installation steps properly. Installing Eclipse This tutorial also covers integration of Ant with Eclipse integrated development environment (IDE). Hence, if you have not installed Eclipse, please download and install Eclipse. Steps to install Eclipse Download the latest Eclipse binaries from www.eclipse.org Unzip the Eclipse binaries to a convenient location, say c:folder. Run Eclipse from c:eclipseeclipse.exe. Apache Ant Tasks – BaseName Description Basename task determines the base name of the specified file/directory while removing the suffix if passed. In case of full path of file, the name of the file is used. In case of directory path, the name of the last directory is used. Properties Sr.No Attributes & Description 1 File The path to take the basename of. (Mandatory) 2 Property The name of the property to set. (Mandatory) 3 Suffix The suffix to remove from the resulting basename (specified either with or without the .). (Optional) Example Usage Create build.xml with the following content − <?xml version=”1.0″?> <project name=”TutorialPoint” default=”info”> <target name=”info”> <basename property=”cmdname” file=”D:/usr/local/application.exe” suffix=”.exe”/> <echo message=”${cmdname}”></echo> </target> </project> Output Running Ant on the above build file produces the following output − F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml info: [echo] application BUILD SUCCESSFUL Total time: 0 seconds Apache Ant Tasks – GZip Description Gzip task creates archive based on GZip, BZip2 or XZ algorithm. Output file is generated only if it is not present or source is newer. Properties Sr.No Attributes & Description 1 src The file/collection to gzip/bzip/xz. (Mandatory) 2 Destfile the destination file to create. (Mandatory) Example Usage Create build.xml with the following content: <?xml version=”1.0″?> <project name=”TutorialPoint” default=”info”> <target name=”info”> <gzip src=”test.txt” destfile=”text.gz” /> <echo>File archived.</echo> </target> </project> Output Create a text.txt file with some content in the same folder. Now running Ant on the above build file produces the following output − F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml info: [gzip] Building: F:tutorialspointanttext.gz [echo] File archived. BUILD SUCCESSFUL Total time: 0 seconds You can verify that the text.gz file created. Apache Ant Tasks
ANT Tasks – Zip
Apache Ant Tasks – Zip ”; Previous Next Description zip task creates a zip file. Properties Sr.No Attributes & Description 1 Destfile The ZIP file to create. 2 Zipfile Old name of destfile. Deprecated. 3 Basedir The directory from which to jar the files. 4 Compress Not only store data but also compress them. Unless you set the keepcompression attribute to false, this will apply to the entire archive, not only the files you”ve added while updating. 5 Keepcompression For entries coming from existing archives (like nested zipfilesets or while updating the archive), keep the compression as it has been originally instead of using the compress attribute. 6 Encoding The character encoding to use for filenames inside the archive. 7 Filesonly Store only file entries. 8 Include comma- or space-separated list of patterns of files that must be included. 9 Includesfile name of a file. Each line of this file is taken to be an include pattern. 10 Excludes comma- or space-separated list of patterns of files that must be excluded. 11 Excludesfile Name of a file. Each line of this file is taken to be an exclude pattern. 12 Defaultexcludes Indicates whether default excludes should be used or not (yes|no). 13 Menifest The manifest file to use. 14 Filesetmanifest Behavior when a manifest file is found in a zipfileset or zipgroupfileset file. Valid values are skip, merge, and mergewithoutmain. merge will merge all of the manifests together, and merge this into any other specified manifests. mergewithoutmain merges everything but the Main section of the manifests. 15 Whenmanifestonly Behavior when no files match. Valid values are fail, skip, and create. 16 Manifestencoding The encoding used to read the JAR manifest, when a manifest file is specified. 17 Index Whether to create an index list to speed up classloading. Unless you specify additional jars with nested indexjars elements, only the contents of this jar will be included in the index. 18 indexMetaInf Whether to include META-INF and its children in the index. Doesn”t have any effect if index is false. Oracle”s jar implementation used to skip the META-INF directory and Ant followed that example. The behavior has been changed with Java 5. In order to avoid problems with Ant generated jars on Java 1.4 or earlier, Ant will not include META-INF unless explicitly asked to. 19 Manifestencoding The encoding used to read the JAR manifest, when a manifest file is specified. 20 Update Indicates whether to update or overwrite the destination file if it already exists. 21 Duplicate Behavior when a duplicate file is found. Valid values are add, preserve, and fail. 22 Roundup Whether the file modification times will be rounded up to the next even number of seconds. 23 Level Non-default level at which file compression should be performed. Valid values range from 0 (no compression/fastest) to 9 (maximum compression/slowest). 24 Preserve0permissions When updating an archive or adding entries from a different archive Ant will assume that a Unix permissions value of 0 (nobody is allowed to do anything to the file/directory) means that the permissions haven”t been stored at all rather than real permissions and will instead apply its own default values. 25 useLanguageEncodingFlag Whether to set the language encoding flag if the encoding is UTF-8. This setting doesn”t have any effect if the encoding is not UTF-8. 26 createUnicodeExtraFields Whether to create Unicode extra fields to store the file names a second time inside the entry”s metadata. 27 FallbacktoUTF8 Whether to use UTF-8 and the language encoding flag instead of the specified encoding if a file name cannot be encoded using the specified encoding. 28 mergeClassPathAttributes Whether to merge the Class-Path attributes found in different manifests (if merging manifests). If false, only the attribute of the last merged manifest will be preserved. 29 flattenAttributes Whether to merge attributes occurring more than once in a section (this can only happen for the Class-Path attribute) into a single attribute. 30 Zip64Mode When to use Zip64 extensions for entries. The possible values are never, always and as-needed. Example Usage Create build.xml with the following content − <?xml version=”1.0″?> <project name=”TutorialPoint” default=”info”> <target name=”info”> <zip basedir=”src” destfile=”src.zip” /> <echo>src archived.</echo> </target> </project> Output Create a text.txt file with some content in the same folder. Now running Ant on the above build file produces the following output − F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml info: [zip] Building zip: F:tutorialspointantsrc.zip [echo] src archived. BUILD SUCCESSFUL Total time: 0 seconds You can verify that the src.zip file created. Print Page Previous Next Advertisements ”;
ANT Tasks – GUnzip
Apache Ant Tasks – GUnzip ”; Previous Next Description Gunzip task extracts an archive using GZip, BZip2 or XZ algorithm. Output file is generated only if it is not present or source resource is newer. If dest is omitted, the parent dir of src is used. Properties Sr.No Attributes & Description 1 src The file/collection to expand. (Mandatory) 2 Dest The destination file or directory. (Optional) Example Usage Create build.xml with the following content: <?xml version=”1.0″?> <project name=”TutorialPoint” default=”info”> <target name=”info”> <gunzip src=”text.gz” dest=”text.txt”/> <echo>File extracted.</echo> </target> </project> Output Let”s extract the a text.gz file to text.txt. Now running Ant on the above build file produces the following output − F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml info: [gunzip] Expanding text.gz to F:tutorialspointanttext.txt [echo] File extracted. BUILD SUCCESSFUL Total time: 0 seconds You can verify that the text.txt file is created. Print Page Previous Next Advertisements ”;
ANT Tasks – Import
Apache Ant Tasks – Import ”; Previous Next Description Import task imports another build file into the project. Properties Sr.No Attributes & Description 1 File The file to import. If this is a relative file name, the file name will be resolved relative to the importing file. Note: this is unlike most other Ant file attributes, where relative files are resolved relative to basedir. 2 Optional If true, do not stop the build if the file does not exist. 3 As Specifies the prefix prepended to the target names. 4 prefixSeparator Specifies the separator to be used between the prefix and the target name. Example Usage Create build.xml with the following content − <?xml version=”1.0″?> <project name=”TutorialPoint” default=”info”> <import file=”nested.xml” as=”nested”/> <target name=”info” depends=”nested.echo”> </target> </project> And a nested.xml with the following content − <project> <target name=”setUp”> <property name=”build.dir” value=”build”/> </target> <target name=”echo” depends=”setUp”> <echo>build.dir is set as build</echo> </target> </project> Above script will create an ear file in the current directory as myapp.ear. Output Running Ant on the above build file produces the following output − F:tutorialspointant>ant Buildfile: F:tutorialspointantbuild.xml setUp: nested.echo: [echo] build.dir is set as build info: BUILD SUCCESSFUL Total time: 0 seconds Print Page Previous Next Advertisements ”;