|
From: Durant S. <si...@mi...> - 2002-09-18 06:20:54
|
Thanks, Tom.
Your email did end up helping me! My goal is to define my classpath
exactly once in my build.xml file for use with ant (and someday make
it platform independent so I can share it with co-developers). So far,
it's working! I think what I have could help others who might want to
use ant, so I'm passing this along to everyone. The run_jyFoo task is
based off the contents of what I found in my jython.bat file. Modify
as necessary for your os.
I have a project that has java as well as jython code in it, something
like this:
<project name="MyProject" default="dist" basedir=".">
<property name="src" location="src"/>
<property name="build" location="classes"/>
<path id="project.class.path">
<pathelement path="."/>
<pathelement path="./${build}"/>
<fileset dir="C:/thirdParty/lib">
<include name="**/*.jar"/>
</fileset>
<!-- more jar files and dirs listed here-->
</path>
<target name="run_jyFoo"
description="Run jyFoo.py with arguments as a test">
<java dir="${build}" fork="true" failonerror="true"
classname="org.python.util.jython"
classpathref="project.class.path">
<jvmarg value="-Dpython.home=C:\Program Files\jython-2.1"/>
<arg value="${src}\myJythonPackage\jyFoo.py"/>
<arg value="Python"/>
<arg value="in"/>
<arg value="java"/>
</java>
</target>
</project>
Calling "ant run_jyFoo" will run jython on src\myJythonPackage\jyFoo.py
for me with three args: "Python" "in" "java"
Users will need to change -Dpython.home=C:\Program Files\jython-2.1
probably. At some point, I'll define that in a property.
Note: I also use this with a jythonc task I found on the web. Someone
mentioned it on this list, so it's in the archives. I can post more on
that later (hopefully I'll find time to implement some uptodate code
in it so every py file doesn't get compiled to a class file
everytime).
The following does not work, I get some error=0 thing when trying to
run the exec (I don't like it anyway, because it would be hard to make
that os independent easily):
<target name="BROKEN_run_jyFoo">
<pathconvert targetos="windows" property="project.class.path.windows"
refid="project.class.path"/>
<exec dir="classes" executable="jython">
<env key="CLASSPATH" value="${project.class.path.windows}"/>
<arg value="${src}\myJythonPackage\jyFoo.py"/>
<arg value="Python"/>
<arg value="in"/>
<arg value="java"/>
</exec>
</target>
----- Original Message -----
From: "Tom Whittaker" <to...@ss...>
To: <jyt...@li...>
Cc: "Durant Schoon" <si...@mi...>
Sent: Thursday, September 12, 2002 3:04 PM
Subject: [Jython-users] How do I specify the classpath on the jython command
line?
> > From: "Durant Schoon" <si...@mi...>
> > Date: Wed, 11 Sep 2002 20:30:37 -0700
> >
> > How do I specify the classpath on the jython command line?
>
> Since 'jython' is a batch file (script), the easiest thing to do is
> modify it accoringly. I use several different one for this purpose.
>
> For example, one of mine is called 'jyj.bat' and contains:
>
> java -mx256m -classpath
".\;c:\jython-21\jython.jar;c:\src\visad\python;.\netcdf2All.jar;.\mcidas.ja
r" %1 %2 %3 %4 %5 %6 %7 %8 %9
>
> Hope that helps.
>
> tom
>
>
> --
> Tom Whittaker
> University of Wisconsin-Madison
> Space Science and Engineering Center
> Cooperative Institute for Meteorological Satellite Studies
> Telephone/VoiceMail: 608.262.2759
>
|