DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Use Maven Ant Plugin To Run Python Test

07.28.2010
| 6049 views |
  • submit to reddit
        Started to use python for some system stuff and wanted to be able to test it with the rest of the code.

The ant plugin is an EZ way to shell out from pom.xml

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <configuration>
                            <tasks unless="maven.test.skip">
                                <echo message="this example run some python test"/>
                                <exec executable="python" error="target/error.from.jobs">
                                    <env key="PYTHONPATH" path="src/main/python"/>
                                    <arg value="src/test/python/test.py" />
                                    <arg value="${test}"/>
                                </exec>
                            </tasks>
                        </configuration> 
                        <goals>     
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>