jython-maven-plugin
A simple maven plugin to run python scripts during maven build – you can now use python 2.7 scripts within a maven run.
You can use the complete standard library that comes with Jython 2.7.
Dependencies for your project
<plugin>
<groupId>rocks.juergen</groupId>
<artifactId>jython-maven-plugin</artifactId>
<version>${jython-maven-plugin.version}</version>
<configuration>
<!-- See configuration details -->
</configuration>
</plugin>
By default, the plugin is bound to the generate-resources
phase. With the <execution>
tag, you can bind it to other phases.
Configuration
Using inline script in POM
The easiest use case is the usage of an inline script, directly included in your POM. Example:
<build>
<plugins>
<plugin>
<groupId>rocks.juergen</groupId>
<artifactId>jython-maven-plugin</artifactId>
<version>${jython-maven-plugin.version}</version>
<executions>
<execution>
<id>execute-python</id>
<goals>
<goal>inline-script</goal>
</goals>
</execution>
</executions>
<configuration>
<python><![CDATA[
for i in range(3):
print 'hello, world!'
]]></python>
</configuration>
</plugin>
</plugins>
</build>
Remark: Due to python's need for correct indentation, your inline python code must begin at the «real» beginning of the line.
Also, using CDATA
is a good practise to keep your POM valid and clean.
If you have only a single line in your inline script, you can shorten the configuration to this:
<python><![CDATA[print 'hello, world!']]></python>
Using script file
A python file can be executed with this configuration:
<build>
<plugins>
<plugin>
<groupId>rocks.juergen</groupId>
<artifactId>jython-maven-plugin</artifactId>
<version>${jython-maven-plugin.version}</version>
<executions>
<execution>
<id>execute-python</id>
<goals>
<goal>file</goal>
</goals>
</execution>
</executions>
<configuration>
<pythonFile>/path/to/python/script.py</pythonFile>
</configuration>
</plugin>
</plugins>
</build>
Executing scripts directly
You might want to execute a python file directly, for example to see if it's compatible.
mvn rocks.juergen:jython-maven-plugin:${VERSION}:exec -Dfile=/path/to/python/script.py
Replace ${VERSION}
with the plugin version, or LATEST
for the latest release.
Project information
License
The plugin source code is licenced under the Apache License 2. See LICENSE for details.
Issue tracker
The project uses Github's Issue Tracker.
Pull Requests
Pull Requests are welcome! Get your fork and send us your Pull Request.
Class Diagram Overview
The jython-maven-plugin consists consists of only a few classes and some more tests.
Siging key
All artifacts are signed with this key:
-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