I am trying to add some tag information in my ant script using the following target but I get an error (Result=-1) and hg tells me it does not recognise the command:
<target name="-post-init">
<exec outputproperty="hg.tag" executable="hg">
<arg value="parents --template {latesttag}+{latesttagdistance}" />
</exec>
</target>
If I only include value="parents" it works fine.
If I run the command line hg parents --template {latesttag}+{latesttagdistance} it works fine too.
Any ideas on what is wrong in my syntax?
Just tried this and it works fine:
<exec outputproperty="hg.tag" executable="hg">
<arg value="parents" />
<arg value="--template" />
<arg value="{latesttag}+{latesttagdistance}" />
</exec>
I needed to split the arguments.
Related
After building EAR file when i'm trying to extract XML file form the EAR i'm getting error [exec] Failed to open properties file : AppManage.tra
<property name="Appmanage" value="C:\tibco\etascbw513\tra\5.10\bin\AppManage.exe" />
<target name="extract">
<exec executable="${Appmanage}">
<arg value="-export"/>
<arg value="-ear"/>
<arg value="${workdir}\Deploy\EARs\${project}.ear"/>
<arg value="-out"/>
<arg value="${workdir}\Deploy\EARs\${project}.xml"/>
<arg value="-max"/>
</exec>
old Q : can someone share simple build.xml to create ear file from ant script
details : i'm able to pull repositories with the help ant script now i want to create EAR file from ant script for Tibco BW. can any one share simple demo .
try to solve this error using below steps.
try to check your environment variable path.
check TRA_HOME/bin/ using App manage utility.
This error "Failed to open properties file : AppManage.tra" occurs because the AppManage executable tries to look for AppManage.tra in the current execution directory and does not find it. In this particular case, the current execution directory would depend on where you are executing Ant from.
The correct way to avoid this error is to provide full path to the AppManage.tra file as an argument to the AppManage executable in the ant exec statement, as shown below, in the highlighted section (two new arguments are added "--propFile" and "full path to AppManage.tra"). Hope this helps.
<property name="Appmanage" value="C:\tibco\etascbw513\tra\5.10\bin\AppManage.exe" />
<target name="extract">
<exec executable="${Appmanage}">
<arg value="--propFile"/>
<arg value="C:\tibco\etascbw513\tra\5.10\bin\AppManage.tra"/>
<arg value="-export"/>
<arg value="-ear"/>
<arg value="${workdir}\Deploy\EARs\${project}.ear"/>
<arg value="-out"/>
<arg value="${workdir}\Deploy\EARs\${project}.xml"/>
<arg value="-max"/>
</exec>
I am trying to add autoprefix-cli to my ANT build. Below is my code.
<target name="auto">
<apply executable="autoprefixer-cli.bat" verbose="true" force="true" failonerror="true">
<arg value="-d" /> <!-- Turn on verbose -->
<arg value="prefix" />
<arg value="*.css" />
</apply>
</target>
When i do a ant build, it gives me an error saying resource not specified.
BUILD FAILED
D:\tempTest\AntTestProject\build.xml:25: no resources specified
Note: I can access autoprefix-cli from command line, its installed with -g flag and also it works when i directly use it from commandline.
The apply task basically loops the exec task on a batch of resources (files, directories, URLs, etc). If you only want to run one command, use exec instead.
However, you will likely also need to alter your command. From Ant's exec task documentation:
Note that .bat files cannot in general by executed directly. One
normally needs to execute the command shell executable cmd using the
/c switch.
https://ant.apache.org/manual/Tasks/exec.html
So instead you should have:
<exec executable="cmd" verbose="true" force="true" failonerror="true">
<arg value="/c" />
<arg value="autoprefixer-cli.bat" />
<arg value="-d" />
<arg value="prefix" />
<arg value="*.css" />
</exec>
<exec dir="${basedir}" executable="cmd.exe">
<arg line="start cmd /c java -jar ${jar.file} "/>
</exec>
In Eclipse this does not work, I would like to open my app.
The reason is io.Console because this I can't execute the app in Eclipse.
cmd appears in two places: In the executable attribute and in the <arg>. It should only appear in the executable attribute.
Further, the /c option of cmd.exe should appear before the start command, not after.
Try the following:
<exec executable="cmd.exe" failonerror="true">
<arg value="/c"/>
<arg value="start"/>
<arg value="java"/>
<arg value="-jar"/>
<arg value="${jar.file}"/>
</exec>
Program works fine when run with eclipse run configurations, but when run with ant, it is unable to parse int from args[0], which I do not understand. Full code is available here https://gist.github.com/4108950/e984a581d5e9de889eaf0c8faf0e57752e825a97
I believe it has something to do with ant,
target name="run" description="run the project">
java dir="${build.dir}" classname="BinarySearchTree" fork="yes">
<arg value="6 in.txt"/>
/java>
/target>
the arg value will be changed via the -D flag, as in ant -Dargs="6 testData1.txt" run.
Any help would be much appreciated, it is very frustrating.
You need to supply the arguments as two different arg values:
<target name="run" description="run the project">
<java dir="${build.dir}" classname="BinarySearchTree" fork="yes">
<arg value="6" />
<arg value="in.txt" />
</java>
</target>
You can also use the line attribute; From the ANT docs:
<arg value="-l -a"/>
is a single command-line argument containing a space character, not separate commands "-> l" and "-a".
<arg line="-l -a"/>
This is a command line with two separate arguments, "-l" and "-a".
Expanding epoch 's answer.
java task supports sysproperty and jvmarg.
For example (from ant java task page)
<java classname="test.Main"
fork="yes" >
<sysproperty key="DEBUG" value="true"/>
<arg value="-h"/>
<jvmarg value="-Xrunhprof:cpu=samples,file=log.txt,depth=3"/> </java>
So you could construct the args from the command line passed to ant.
<target name="run" description="run the project">
<java dir="${build.dir}" classname="BinarySearchTree" fork="yes">
<sysproperty key="testarg" value="${testarg}"
<arg value="${arg1}" />
<arg value="${arg2}" />
</java>
</target>
Now if you call ant with ant -Dtestarg=test1234 -Darg1=6 -Darg2=in.txt, then testarg will be available via property. Others will become normal arguments to the java program.
This may be a naive question for the people who are familiar with Ant. I am new to Ant. please do me a favor. Thanks!
I write something like this in build.xml.
<target name="run">
<java jar="build/jar/sth.jar" fork="true"/>
</target>
But, I want to put some parameters to it, like
java -jar build/jar/sth.jar input.txt
How to do that?
By the way, where could I find the specifications of build.xml grammar? like how many attributes are there? what are the other attributes rather than "jar" "fork"?
This should do what you want:
<exec executable="java">
<arg value="-jar" />
<arg value="build/jar/sth.jar" />
</exec>
Here is the source of documentation http://ant.apache.org to start with.
EDITED:
You can use java tag as well, simply specifying tag args="input.txt" or whatever parameters you would like to pass. More info on java command
<java jar="build/jar/sth.jar">
<arg value="input.txt" />
</java>