Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Jython with Maven

Tags:

maven-2

jython

I have a Maven module, that depends on various other Maven dependencies by which I am accessing through my jython code.

I am now done, and I would like to compile the project as a .jar, or even just run it without compiling, but I have no clue where to start.

Does anyone have any idea how I can run some .py files that accesses some Java libraries in other packages?

Also, how can I compile it as a .jar file when all is done and good?

Thanks!

like image 309
nubela Avatar asked Sep 07 '10 15:09

nubela


1 Answers

Compiling and integrating python

Use the jython-compile-maven-plugin. It allows you to deploy a standalone project that includes jython with libraries.

For demonstration of this plugin, see the demo project and its source code. It shows how to

  • launch a python console -- look at AbstractInitJython and InitJython on how to launch a python/jython console, how to execute python code snippets, and how to run a python script.

  • include python libraries -- the plugin also downloads and bundles python libraries (using easy_install) in the package phase, and adds them to the jar. The resulting jar can have all the libraries of the project, all pom dependencies and all the python libraries requested. The demo project shows this with the "nose" python library (see the pom file).

Testing python / jython code

The python-test-maven-plugin allows you to run your python tests alongside the normal junit tests. The demo project (look at the source at source code) shows the use of standard python unit tests (with nose) and BDD (behaviour testing) with the lettuce-clone freshen.


The sourceforge umbrella project is http://mavenjython.sourceforge.net/

Unlike maven-jython-plugin, they don't use the outdated jythonc compiler.

like image 184
j13r Avatar answered Oct 09 '22 00:10

j13r