Ant script to fetch property value from another property file - ant

I have 2 properties files as below
a.properties has list of property names
b.proprties has list of its corresponding values
a.properties
Application=
ApplicationID=
BU=
b.properties
ACCSRV
ACCSRV
BT
I am looking for ant script which can give me final properties file with out out as below:
Final.properties:
Application=ACCSRV
ApplicationID=ACCSRV
BU=BT

Sounds like you need an external tool for this. If you can depend on unix tools, you can use the paste command (see man paste) and run it from ant using the exec task. If not, you can either
write the tool in java, then use tasks javac and java to compile and run it from ant
or use the script task to embed the tool in your ant script using some scripting language

Related

Netbeans build.xml to execute when using Ant

I'm relatively new to using build files and Ant to compile and execute from a command line so i wanted to know how it would be possible to modify the build-impl.xml file auto generated from netbeans so that after it compiles it also executes the program.
Currently when i type just "ant" in the command window where the build.xml file is listed it compiles and etc but then says
-do-jar-copylibs:
[copylibs] Nothing to copy.
[echo] To run this application from the command line without Ant, try:
[echo] java -jar "C:\Users\Eric\Documents\Word Documents\Java Test Code\NetbeansVersion\Cops\dist\Cops.jar"
I can run that command and it will run fine, but i want the program to execute by just typing ant.
The build.xml file - Pastebin
Build-impl.xml file - Pastebin
There are a couple "tasks" available in ant that you could use to accomplish this.
You can use either of these:
Java Task,
Exec Task
Those documentation pages provide examples as well. Before you go there though, you might want to start at the basic manual to get an idea of the structure of an ant build file to determine where and how you want to add this execution step in.
It feels a little "off" to me to have your build script executing the program, but I'm sure you've got a reason, so I might suggest adding a new target that does the build steps and then also runs this command to kick off the program. That way you've still got the option of running the build without running the program.

Retrieval of Jenkins environment variables while invoking ANT

I am invoking a windows batch command from Jenkins, after i get the latest version of my project from SVN. the windows batch command just performs certain file copying, after the all the files are retrieved from SVN and runs an ANT build. In the ANT build process, i am generating a JSP file where i have tried to capture the in the following fashion.
%BUILD_TAG%-%BUILD_NUMBER%-%BUILD_ID%-%SVN_REVISION%
Unfortunately none of this information is understood by the build process and it just writes %BUILD_TAG%-%BUILD_NUMBER%-%BUILD_ID%-%SVN_REVISION% into the file.
Could you please let me know if there is a way to capture these information into a file in the way i am trying to do? if not, could you direct me on how these information could be captured into a JSP file during the process that we are following?
BUILD_TAG, SVN_REVISION, etc are all environment variables that are present during a Jenkins build, and to use them in Ant, you would use them as any other environment variable from Ant
First, add a line:
<property environment="env"/>
Then you can reference any environment variable with this prefix, like:
${env.VAR_NAME}
So in your case, you'd do:
${env.BUILD_TAG}-${env.BUILD_NUMBER}-${env.BUILD_ID}-${env.SVN_REVISION}

Using Listeners&Loggers in build.xml

I want to use Listeners&Loggers in my script build.xml
I have seen the suggested method, but it is on cmd -logger org.apache.tools.ant.listener.ProfileLogger
Also gone through groovy method, but is there any other way I can specify Listeners&Loggers in my script.
Thanks
RSA is built on Eclipse. Both let you select an Ant builder for a project. Which gives you all the Ant options including a command line.

How can I run custom tools from a premake build script?

I'm using protocol buffers for data serialization in my C++ application. I would like to add the invokation of the protoc code generator in my premake build script (thus ensure the up-to-date state of the generated classes and avoid the need to store generated source under version control).
Even their FAQ has a question and answer about this, but the answer is very incomplete for me. Having the ability to call any lua function is great, but where exactly do I put that call? I need to run the protoc compiler before building either the application or the unit tests.
You can certainly call outside code from Premake scripts. But remember: Premake scripts are used to generate build files: Makefiles, C++ projects, etc. The Premake script is run before building the project.
If you want this preprocess to be run outside of the actual build files (and not by make, VC++, Code::Blocks, etc), then it's easy. Lua's os.execute will execute a command-line.
Premake scripts are still Lua scripts. All of the Premake commands are just Lua calls into functions that Premake defines. Premake executes the scripts, then uses the data from them to generate the build files. So all of your Lua code is run during the execution of the script. Where you put this command in your script is irrelevant; wherever it is, it will execute before your build files are generated.
And if you want to run the protoc step during the build (from VC++, makefile, etc.) you can set up a prebuild command. See http://industriousone.com/prebuildcommands for more info and an example.

ANT global property file in Intellij IDEA?

How to set a global property file so that contain the defined properties are getting resolved during my ANT build in Intelliji IDEA?
In Eclipse I can do this via the "Properties" tab in the "Window/Preferences/Ant/Runtime" config.
How can I set this in Intellij IDEA 9 or 10 ?
IDEA allows you to specify custom properties for the build script, but not via file:
Use this tab to specify the runtime properties that should be passed to the build script. These properties are equivalent to the ones defined after the -D option of the command line. A property is defined as a pair "name-value". The value can be hard-coded, or dynamically evaluated at runtime from a macro.
If you want to use a file, then you need to reference properties file from the build.xml:
Alternatively you can execute the Ant build script on the command shell (View > Tool Windows > Terminal). The command ant can load specific property files, e.g.: <property file="./resources/build.properties" />.

Resources