I am relatively new in ant, at school I have an assignment to do a build file. One of my questions is to copy to "/foldercopy" the file whose name(or path) is taken as argument for ant. I need to do something like:
ant cpfile file.txt
So ant will copy the file.txt to /foldercopy. I searched a lot on google but all I could find was something with "-Darg", but my teacher said that it's not correct. Is there any way to do it?
Discussion. If you want to pass arguments to Ant, you can enter those arguments in the Arguments box of the dialog opened by right-clicking your build file, clicking Run Ant, and clicking the Main tab. You can see that dialog in Figure 7-15 (note that you also can set the build file location and base directory here).
To run the ant build file, open up command prompt and navigate to the folder, where the build. xml resides, and then type ant info. You could also type ant instead. Both will work,because info is the default target in the build file.
Description. Call another target within the same buildfile optionally specifying some properties (params in this context). This task must not be used outside of a target . By default, all of the properties of the current project will be available in the new project.
Ant is a Java-based build tool created as part of the Apache open-source project. You can think of it as a Java version of make. Ant scripts have a structure and are written in XML. Similar to make, Ant targets can depend on other targets.
Plain command line arguments to ant
are considered to be target names, so if you want to pass arguments to your target you need to use properties, via -D
:
ant -Dfile=file.txt cpfile
and access the value as ${file}
inside build.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With