I have a C:\Users\Sony\Desktop\Project\Workspace\testpython\verify_fam_extended.xml:52: Execute failed: java.io.IOException: Cannot run program "python" (in directory "C:\Users\Sony\Desktop\Project\Workspace\testpython\backend\generated"): CreateProcess error=2, The system cannot find the file specified error when I run my xml code through Ant.
<exec dir="backend/generated" executable="python">
<arg line="toplevel.py"/>
<env key="PYTHONPATH" value="${dsltrans.install.path}:./backend/generated"/>
</exec>
edit python.exe must be in a directory defined in the executable path variable PATH.
Following working example assumes the presence of C:\Python33\python.exe
<project name="demo" default="main" basedir=".">
<property environment="env" />
<echo>PATH is set as: ${env.PATH}</echo>
<target name="main">
<exec dir="backend/generated" executable="python">
<arg line="--version"/>
</exec>
</target>
</project>
execute in a command session
set PATH=C:\Python33;%PATH%
ant
output
Buildfile: X:\temp\build.xml
[echo] PATH is set as: C:\Python33;...
...
main:
[exec] Python 3.3.0
edit Just checked. The executable can be executable="python" or executable="python.exe". So #cdarke is right the issue is that python.exe is not in PATH.
Related
I have a cmd script file, which sets all the environment values and invoke ant class to build the java project.
I have:
<property environment="env"/>
set in build.xml and
<property name="CD" value="${env.CDTEC}"/>.
build.xml unable to read these env values set from the cmd script file. If I echo the values from command prompt that prints, but not from the ant.xml file. Getting the error as
BUILD FAILED
c:\Users\test\Projects\Spring testing\build.xml:85: c:\Users\test\Projects\Spring testing\${env.CDTEC}\lib does not exist.
I added echo message in build.xml
as
<echo message="Message from ${this.CDTEC} Client" />
and printing that as
'Message from {env.CDTEC} Client'.
Command prompt is printing these values but Ant is not able to access these env values, any idea why?
Is the environment variable set externally to ANT?
Example
Setting the variable and calling ANT
$ CDTEC=hello ant
Buildfile: /....../build.xml
build:
[echo] CDTEC=hello
build.xml
<project name="demo" default="build">
<property environment="env"/>
<target name="build">
<echo message="CDTEC=${env.CDTEC}"/>
</target>
</project>
I'm trying to use Daikon to test a large project so I needed ant to compile and run everything for me. Since I'm new to ant I'm trying to get familiar with it through a simple example given to Daikon. So, the best candidate example is the associated StackAr package with Daikon.
To run Daikon normally I will execute the following command after compiling all the java files I'm targeting.
java daikon.Chicory --daikon DataStructures.StackArTester
which is equivalent to this command
java -cp "/usr/lib/daikonparent/daikon-5.2.20/daikon.jar:." daikon.Chicory --daikon DataStructures.StackArTester
Both commands will run daikon.jar using Chicory interface with the flag --daikon and will take the StackArTester.class to instrument it and run it.
Now, my attempt to run the same command using ant looks as the following:
<project name="StackAr" default="compile" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="DataStructures"/>
<property name="build" location="DataStructures"/>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
</target>
<target name="compile" depends="init"
description="compile the source">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}"
destdir="."
debug="on"
/>
</target>
<target name="run" description="run StackArTester">
<java classname="DataStructures.StackArTester">
<classpath>
<pathelement location="."/>
</classpath>
</java>
</target>
<target name="inv" description="run daikon">
<java classname="daikon.Chicory" >
<arg value="--daikon" />
<arg value="DataStructures.StackArTester"/>
<classpath>
<pathelement path="/usr/lib/daikonparent/daikon-5.2.20/daikon.jar"/>
</classpath>
</java>
</target>
<target name="clean"
description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
</target>
</project>
The target compile is used to compile all the source files and is working. Also, the target run is used as a test to run the targeted .class file and is working. The target inv is where I'm having trouble and it's suppose to be equivalent to the two command above.
My issue is that I'm not sure how I'm suppose to pass the .calss file to Daikon. From the results I have seen I'm positive that first argument/flag --daikon is recognized. However, for the second argument DataStructures.StackArTester in most of my tires I see that it's recognized, but Daikon has an issue with its classpath. Runing the script above ant inv will generate the following error message:
Buildfile: /usr/lib/daikonparent/daikon-5.2.20/examples/java-examples/StackAr/build.xml
inv:
[java]
[java] Executing target program: java -cp /usr/share/ant/lib/ant-launcher.jar:/usr/lib/daikonparent/daikon-5.2.20/daikon.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar:/usr/share/ant/lib/ant-testutil.jar:/usr/share/ant/lib/ant-apache-log4j.jar:/usr/share/ant/lib/ant-javamail.jar:/usr/share/ant/lib/ant-jsch.jar:/usr/share/ant/lib/ant-apache-regexp.jar:/usr/share/ant/lib/ant-antlr.jar:/usr/share/ant/lib/ant-swing.jar:/usr/share/ant/lib/ant-apache-oro.jar:/usr/share/ant/lib/ant-apache-bcel.jar:/usr/share/ant/lib/ant-apache-xalan2.jar:/usr/share/ant/lib/ant-junit.jar:/usr/share/ant/lib/ant-launcher.jar:/usr/share/ant/lib/ant-apache-bsf.jar:/usr/share/ant/lib/ant-jdepend.jar:/usr/share/ant/lib/ant-apache-resolver.jar:/usr/share/ant/lib/ant-jmf.jar:/usr/share/ant/lib/ant-commons-logging.jar:/usr/share/ant/lib/ant-commons-net.jar:/usr/share/ant/lib/ant-junit4.jar:/usr/share/ant/lib/ant.jar:/usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar -ea -Xmx1000m -javaagent:/usr/lib/daikonparent/daikon-5.2.20/java/ChicoryPremain.jar=--daikon --dtrace-file=StackArTester.dtrace.gz DataStructures.StackArTester
[java] entered daikon.chicory.Runtime.setDtrace(./StackArTester.dtrace.gz, false)...
[java] Error: Could not find or load main class DataStructures.StackArTester
[java] Chicory warning: No methods were instrumented.
[java] Warning: Did not run Daikon because target exited with 1 status
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 0 seconds
Note that the error is
Error: Could not find or load main class DataStructures.StackArTester
I'm out of ideas about what I might try. Hopefully the information above is enough. Please note that I'm in the same directory when executing the original commands and the ant command.
Thakns ...
The error
[java] Error: Could not find or load main class DataStructures.StackArTester
means that Java did not find the class DataStructures.StackArTester on your classpath.
On the line that starts with [java] Executing target program, the -cp command-line argument is your classpath. The classpath must contain a directory or jar file containing DataStructures/StackArTester.class. You just need to augment the classpath.
I have an ant build for a java project that I would like to trigger from within eclipse, that in turn launches a cygwin window that executes a deployment script. Is it possible to implement this without calling a new command window from ant?
Use bash.exe as the executable (replacing or parameterizing cygwin directory as needed):
<project default="default">
<target name="default">
<exec executable="c:/cygwin/bin/bash.exe">
<arg value="-c"/>
<arg value="ls c:/"/>
</exec>
</target>
</project>
I'm looking for a way to run play dist through an Ant build script. I've looked into using the exec task but it is not working for me. Here is what I tried:
<target name="deploy">
<exec executable="play">
<arg value="dist" />
</exec>
</target>
I'm getting this error:
C:\Users\path\to\build.xml:39: Execute failed: java.io.IOException: Cannot run program "play": CreateProcess error=2, The system cannot find the file specified
Play is already in my Path environment variable and I can execute it from the command line by typing play so that isn't the problem. I'm not allowed to use absolute paths due to sysadmin constraints.
Any ideas?
Ended up manually searching for the Play executable and storing the property to use in the exec task:
<exec executable="where" outputproperty="play.dir" osfamily="windows">
<arg value="play.bat" />
</exec>
<exec executable="which" outputproperty="play.dir" osfamily="unix">
<arg value="play" />
</exec>
<exec executable="${play.dir}" dir=" ... ">
<arg value="dist" />
</exec>
When I run Ant build using mysql the following error occur
Cannot run program "mysql" (in directory
"D:\Projects\OBSWorkspace\schoolforms\db"):
CreateProcess error=2, The system cannot find the file specified
when i run mysql in local cmd the following message occur
ERROR 1045 (28000): Access denied for user 'ODBC'#'localhost' (using password:
NO)
how to run ant for generating and creating database from the script.
First of all you need to try to connect with mysql via cmd line, for example int this way mysql -u root -p root to know that you are able to do it. Secondly you can do it from ant build using this code:
<project name="mysql.test" default="mysqltest">
<target name="mysqltest">
<exec executable="cmd.exe">
<arg value="mysql" />
<arg value="-u root" />
<arg value="-p root" />
</exec>
</target>
</project>
You probably try to do it not via cmd and thats why you can't connect.