indexof : similar function in ant - ant

I am using ant and Could anyone please let me know if there is similar function as indexof in ant.
If the index is greater than 1, it should implement a different logic.
Thanks

I don't know what you want to do exactly, but ant offers translate and replace tasks as well as a script task from which you can call JavaScript. See the manual.

Related

Where is the source code for Apache Ant "Apply" task?

I am looking for the source code that implements the apply task in ant. I have been search through the sources at:
http://svn.apache.org/repos/asf/ant/ant-core/trunk/
Alas, grep and find have not revealed its whereabouts! I must be looking in the wrong place. Anyone know where this source file is?
The file org/apache/tools/ant/taskdefs/defaults.properties gives the mapping between XML element names and the implementing classes. In the case of apply it looks like the class is Transform, which in turn is a no-op subclass of ExecuteOn (as execon is a deprecated alias for apply).

How do I perform if/else operations in a jenkins workflow build?

I'm sure there's an easy answer for this but I was unable to find it elsewhere.
I have a Jenkins workflow job with parameters. What I want is to skip a build job depending on the value of a parameter. Something like:
if(param["MYPARAM"]){
build("jorb1")
}
build("jorb2")
Does anyone know how I'd accomplish this?
Turns out the answer is really easy. Hopefully this will help someone else. If statements do work in the DSL configuration. I guess its based on groovy (which I have zero experience with). Anyway my guess was just about right other than specifying the params incorrectly. Below is an example of checking a string parameter:
if(params["MYPARAM"]=="some_value"){
build("jorb1")
}
build("jorb2")

Dynamic property names in ant

I am reading a file in ant and loading the properties through loadproperties. I am interested in using the value of a specific property, whose name is not known. I know that it follows a pattern because that is how I load the property.
I can echoproperties and see that it is being loaded.
But I dont know how to access its value, given that its name is actually a pattern rather that hardcoded.
How can I access this property's value to do some processing.
I hope this is clear. Please ask if I need to clarify some more.
Take a look at ant-contrib package. Its propertycopy task will do what you need. If you need to resolve an arbitrary number of properties following an established pattern, you would use ant-contrib's propertycopy in conjunction with ant-contribs "for" task.
http://ant-contrib.sourceforge.net/tasks/tasks/index.html
You should use Ant's script task.
I suggest using the beanshell script since it is pure java.
For example, to print all properties for your project, use the following:
<target name="echoprops">
<script language="beanshell">
System.out.println("All Properties: " + project.getProperties().keySet());
</script>
</target>
It should be easy to modify the above script to get the property you want.
To use this task, you will need to run the following in $ANT_HOME first:
ant -f fetch.xml script -Ddest=user
That will download all required optional jars to ~/.ant/lib .

Where can i find an msi conditions parser

I am looking for a library or utility that can parse the msi launch conditions. Basically i want to take these statements and translate them into our own langauge, but before i do that i need to parse it up.
I can already pull a list conditions out of an MSI, for example:
NOT VersionNT OR (VersionNT = 501 AND ServicePackLevel >= 2) OR (VersionNT > 501)
But i was hoping there was already something that can break this up into a more interpretable format.
Additional question, what is this language called? I can figure out how to refer to it or search for it.
Cheers
See:
Conditional Statement Syntax
Windows Installer exposes a Win32 function and an Automation Method for evaluating conditions.
MsiEvaluateCondition Function
Session.EvaluateCondition Method
Try the Wine source code. They have the following grammar file for conditions:
http://source.winehq.org/source/dlls/msi/cond.y

Appending JVM parameter to the parameter specified explicitly in plugin configuration?

Sometimes I need the parameter to be appended, instead of overriding the one in configuration:
for instance
mvn test -DargLine="-Dportal.test=huge"
should be added to
<argLine>-XX:+CMSClassUnloadingEnabled</argLine>
so the result would equal to
<argLine>-XX:+CMSClassUnloadingEnabled -Dportal.test=huge</argLine>
Could please anybody tell me if it is possible and how ?
EDIT: Please don't answer with " Why would you want to do that" kind of annoying questions.
I have never used argLine but maybe this is what you are looking for.. i.e.:
<argLine>-DskipTests=true ${argLine}</argLine>
(I used skip tests as an example :))

Resources