Jython Maven Plugin

Execute Python Scripts during Maven Build

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

rocks.juergen
ArtifactId

ArtifactId

jython-maven-plugin
Last Version

Last Version

0.3-20161016132151+16f07eb
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Jython Maven Plugin
Execute Python Scripts during Maven Build
Project URL

Project URL

https://github.com/juergen-rocks/jython-maven-plugin
Source Code Management

Source Code Management

https://github.com/juergen-rocks/jython-maven-plugin

Download jython-maven-plugin

How to add to project

<plugin>
    <groupId>rocks.juergen</groupId>
    <artifactId>jython-maven-plugin</artifactId>
    <version>0.3-20161016132151+16f07eb</version>
</plugin>

Dependencies

compile (3)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.2.5
org.python : jython-standalone jar 2.7.0
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.2

test (3)

Group / Artifact Type Version
org.apache.maven : maven-compat jar 3.2.5
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 3.3.0
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Build Status Coverage Status GitHub license GitHub issues GitHub forks Maven Central

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.

Class Diagram

Siging key

All artifacts are signed with this key:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2

mQINBFf7gowBEAD4n7xBlwUPec0vgkKdPrTSuxMJsEv2InLFfkdpROuxwAfoiE6M
HTmHnDvrf02oaalgfP5+cwOLCPTgFCXmMnpyVIQLZgucr1cwMHYbfWcGayXuyMQQ
YpMPRxzPRZ/BIZQ+Qg8r1/HOvCUOfa5zveX/oLGgUFIIbokOYG9+Krka5GL16tiY
6C5y3DbzPG+l04WhsUhQGdkDfNqa8SzzhdwxiMKi3hZFObXCffw9KCMadTEfLAEr
43NJg++kiWcF56w78YUwrNUuVAFEuMbzGEnPuLUzXGsUCicaUNksA64MnwSDDOkn
oJn5juVy0ky4UdW1PtvIWGbkgmbGQZqGjHjx2SPobSmKuz2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qqRan8bkBrbjCsfK75dvkfAOxBJhv1Wo5UQM3UP3cq5oBDB
134YPuBOCTrCcND/M+PkgZ9UDPELPrtlgY9kZZRnE2C52BPiW3MbpCknJ9kPnXIq
wdhZSoOUhsKkX17aQSK/H+O2ycZT60U4S1gmo3A3iBdKY566AN5kXJQl4mtXTlO2
a63T
=Kg9S
-----END PGP PUBLIC KEY BLOCK-----
rocks.juergen

juergen.rocks

Versions

Version
0.3-20161016132151+16f07eb
0.2-20161011080554+39de0b4
0.1-20161010165350+196540c
0.1-20161010155937+196540c