I use the Ant cvs and sql tasks to check out and deploy a full code set of database objects. I also use the Ant cvschangelog task to generate a list of what has changed between two tags. It seems that there should be some way of defining a target process that would iterate over the list of elements from the generated changelog xml file and only execute files that have changed between two tags (all of the files use "CREATE or REPLACE" syntax and only replaceable objects are of interest here).
Is there any native Ant solution for this or will a custom task to parse the xml file be necessary?
You might investigate the ant-contrib tasks for looping constructs. The for or foreach task may be just what you need.
Here is an example :
http://franckbehaghel.free.fr/antTask/
Last time I checked Ant didn't support any sort of looping constructs, so you'll have to write your own custom task> However, there is an xslt task that lets you apply stylesheets to xml files. It will depends on what you want to do with the xml itself.
Related
I have the following requirement.
from Ant xmlproperty task. What happens when there is more than one tag with the same name?
it's clear how to repeat for each file.
My requirement is to iterate for each file and I would like to get the value of 'machine' element for corresponding file
eg:
<echo>${PREFIX.main.tagList.tag.file[file1]}</echo> // should return machine1
<echo>${PREFIX.main.tagList.tag.file[file2]}</echo> // should return machine2
An example would help, but I think I discovered this limitation in the xmlproperty task before. For performing complex processing of external files I would use an embedded groovy task, which just loves XML :-)
You haven't specified a sample input, so here's a similar example:
Parse HTML using with an Ant Script
I have a directory with a list of property files for different environment(DEV/STG/QA etc.,)
I want to call an Ant target in a loop with each of this file. How do I do this. I downloaded ant-contrib and tried using the foreach but I couldn't find any example where I can read property files one at a time and call the target. Any suggestions?
I have been looking at a lot of samples on this site and online, nothing seem to match my requirement.
As per apacche documentation : https://ant.apache.org/manual/Tasks/property.html
<property file="foo.properties"/>
reads a set of properties from a file called "foo.properties".
so, if you have my.var=25 , then ${my.var} will get you its value 25. For your requirement you can iterate through the files based on 'env' name & do required tasks.
I have an ant build which contains tasks of format
build
build.foo.bar
So to add dependencies in gradle the first one is easy
build.dependsOn(...)
But the second one is interpreted as method nesting. I suspect there's a standard groovy way to do this but I haven't cracked it.
How do I reference an ant task containing periods in an build.gradle file?
project.tasks['build.foo.bar'].dependsOn(...)
should do the trick.
See Project.tasks, which returns a TaskContainer (extending TaskCollection), and TaskCollection.getAt() which, as its doc says, can be called using the [] operator.
What is the main difference between for and for each.
I am working with websphere mqfte to transfer files using ant scripts.
I need my files to renamed and send to another folder as below :
eg: src : \src\*.txt the files in destination should be \dest\kk_*.cpp (The * indicates the filename. Need all the files to to renamed as follows).
Can anyone help me on this???.
The main difference between for and foreach task from antcontrib =
for uses sequential like macrodef whereas
foreach opens a new project scope for each iteration - like other tasks as
ant, antcall, and subant.
That means because of performance issues the use of for task should be favored.
For your renaming problem => you should use copy or move task with
a nested mapper as already stated by other fellows.
What's the reason to act against standard ant usage !?
btw. because antcontrib development seems to be dead - last release back in 2006 :
there's a new ant addon with similar features => ant flaka
Use the copy task with a glob or regexp mapper. Don't know what for and for each have to do with this question, though.
The for and foreach tasks are not part of core Ant, most likely they are the ones in the ant-contrib collection.
According to the ant-contrib for task docs:
This task is the same as the <foreach>
task, except that
* it uses a nested sequential for each iteration; and
* it implements an additional "keepgoing" attribute.
<for> makes use of ant's macrodef
task, so the #{} notation is used for
parameter substition.
I want to extract values defined in an item group collection of TFSBuild.proj file in a C# application during a build . Can someone give me an idea as to how this can be done.
"Extract" is a weird word to use here. If you're wanting to combine C# with MSBuild, you generally do that by creating an MSBuild Task. Tasks take inputs, which can be ItemGroups and they do stuff with the items in the group.