Java 如果python脚本出现任何错误,如何使maven构建失败
我在maven项目中使用python脚本,如果python脚本出现任何错误,我希望生成失败并显示正确的错误消息Java 如果python脚本出现任何错误,如何使maven构建失败,java,python,maven-2,maven-3,Java,Python,Maven 2,Maven 3,我在maven项目中使用python脚本,如果python脚本出现任何错误,我希望生成失败并显示正确的错误消息 插件里有什么东西吗。如果python出现错误,我们可以从中失败构建并显示日志记录错误 这是我的pom.xml <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artif
插件里有什么东西吗。如果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>
添加
exit
如果要引发错误:
import logging
name = "Amit"
age = 24
if name != "Amit":
logging.error("name is not matching")
exit(1)
if age != 24:
logging.error("age is not matching")
exit(1)
退出时返回的代码等于零。你能解释一下插件中有什么东西吗。如果python程序以错误代码终止,那么构建和显示日志错误Maven应该失败。我看不到python生成的错误日志
import logging
name = "Amit"
age = 24
if name != "Amit":
logging.error("name is not matching")
exit(1)
if age != 24:
logging.error("age is not matching")
exit(1)