This plugin will allow you to integrate a modern jython installation to your project, to
# In your project, add a Jython dependency.
<dependency> <groupId>org.python</groupId> <artifactId>jython-standalone</artifactId> <version>your-jython-version-here</version> </dependency>
# Add this Mojo as a packaging plugin
<build> ... <plugins> ... <plugin> <groupId>net.sf.mavenjython</groupId> <artifactId>maven-jython-compile-plugin</artifactId> <version>your-plugin-version-here</version> <executions> <execution> <phase>package</phase> <goals> <goal>jython</goal> </goals> </execution> </executions> <configuration> <libraries> <param>nose</param> </libraries> </configuration> </plugin> ... </plugins> </build>
The configuration part is optional, but allows you to add libraries to your jython installation.
# Write code to call Jython, and write Python code
Best practice is to put your python modules into src/main/resources/Lib (or src/main/scripts/Lib and configure maven to copy correctly).
Write a Jython initialization class to call the python interpreter or to make a python console. Look at the demo project for inspiration.
It performs the following steps:
Maven will package jython with the jar once you use jar-with-dependencies. Jython will find the libraries in Lib/. Jython will find your code (if you put it in Lib/). You can package Jython as an embedded scripting environment and deploy 3rd-party and your own libraries in a standalone jar.