How to import a variable value from txt file in ant? - ant

I am relatively new to Ant, I have written an ant build file that will open command prompt in windows 7 and pass an argument line.
So how would I pass a variable in this argument line whose value it will get from a txt file in a certain folder?

Try the loadfile task.
See documentation and this answer for examples

Related

Ant Script to find substring

How to write ant script to get a substring from one property file and copy in another property file?
For Eg. I am getting oracle_12c in a property file but now I want to store oracle in one value and 12c in another value in a property file.Can anyone suggest how to write antscript for this.

Replacing dos executable names with custom short names?

I've been using the command prompt to practice assembly programs and I wish to use notepad++ as the editor. Adding notepad++ to the path will do the job but I don't want to type 'notepad++' each time I have to edit a file. Is there a way I can change the name of the executable? Without having to rename the application name.
You could create a quick batch file called, say, npp.cmd. That batch file only needs to have this in it:
#"C:\Program Files (x86)\Notepad++\notepad++.exe" %*
Put npp.cmd somewhere in your path (I have a C:\tools directory for batch files like this) and off you go.
Or associate your assembler sources with Notepad++.
ASSOC .asm=asmfile
FTYPE asmfile="C:\Program Files (x86)\Notepad++\notepad++.exe" "%1"
Then you can edit *.asm files with Notepad++ by double clicking on it in Explorer or by writing it's name in command prompt.

Running spss syntax file on multiple data files automatically

I have a spss syntax file that I need to run on multiple files each in a different directory with the same name as the file, and I am trying to too do this automatically. So far I have tried doing it with syntax code and am trying to avoid doing python is spss, but all I have been able to get is the code bellow which does not work.
VECTOR v = key.
LOOP #i = 1 to 41.
GET
FILE=CONCAT('C:\Users\myDir\otherDir\anotherDir\output\',v(#i),'\',v(#i),'.sav').
DATASET NAME Data#i WINDOW=FRONT.
*Do stuff to the opened file
END LOOP.
EXE.
key is the only column in a file that contains all the names of the files.
I am having trouble debugging since I don't know how to print to the screen if it is possible. So my question is: is there a way to get the code above to work, or another option that accomplishes the same thing?
You can't use an expression like that on a GET command. There are two choices. Use the macro language to put this together (see DEFINE in the Command Syntax Reference via the Help menu) or use the SPSSINC PROCESS FILES extension command or your own Python code to select the files with a wildcard.
The extension command or a Python program require the free Python Essentials available from the SPSS Community website or available with your Statistics version.

How to get a filename without extension in ant

I know how to get the basename for a file with java's ANT build tool, but in this case I want to change the name of a file to include a build version number. Unfortunately the file's name gets set in another ant script (from the android system) which I am importing and I'm not able to set the property for that file or the imported script will complain that the property should not be set already. Thus, if i have a property holding MyApp-release.apk and I want to change the value to MyApp-release-1.10.apk how would I do this? I know I can put the 1.10 at the start of the filename with basename and that's probably what I will do, but I'd rather do it the other way.
Form http://ant.apache.org/manual/Tasks/basename.html:
Task to determine the basename of a specified file, optionally minus a
specified suffix.
<basename property="cmdname" file="D:/usr/local/foo.exe"
suffix=".exe"/>

Ant file path question

I have an Ant file that has this as a path. TRying to find out what it might mean.
deploy.dir = ${basedir}/..
First there is nowhere I can find where ${basedir} is being set. Is this some variable type being set in another file on the server or does ${basedir} mean the same directory the build file is in?
Then what does /.. mean after it.
Thanks
http://ant.apache.org/manual/using.html will explain that ${basedir} is, by default, where you are sitting when you type 'ant'.
.. means what it means on Windows and Linux in pathnames: one directory up.
The default value of ${basedir} is the directory containing your build xml file. This is even true if you say basedir="." in the project element. However, if on the command line, you say:
-Dbasedir=.
then it will be where you are sitting when executing ant. Since in most cases the build xml file will be where you are sitting, the difference shouldn't matter.

Resources