我在maven项目中使用python脚本,如果python脚本出现任何错误,我希望生成失败并显示正确的错误消息
插件里有什么东西吗。如果python出现错误,我们可以从中失败构建并显示日志记录错误
这是我的pom.xml
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<configuration>
<executable>python</executable>
<workingDirectory>src/main/resources/</workingDirectory>
<arguments>
<argument>my.py</argument>
</arguments>
</configuration>
<id>python_build</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
这是我的python脚本my.py
import logging
name = "Amit"
age = 24
if name != "Amit":
logging.error("name is not matching")
if age != 24:
logging.error("age is not matching")
如果要引发错误,请添加
exit
:相关问题 更多 >
编程相关推荐