我正在尝试从 python 脚本运行 Maven 项目。我已经安装了 apache maven。运行命令:mvn exec:java -D"exec.mainClass"="org.matsim.project.RunMatsim"
从终端在 pom.xml 所在的项目文件夹中,不会产生错误并且项目运行正常。
但是当从我的 python 脚本运行以下代码时
import subprocess as sp
def execute(cmd):
popen = sp.Popen(cmd, stdout=sp.PIPE, universal_newlines=True,shell=True)
for stdout_line in iter(popen.stdout.readline, ""):
yield stdout_line
popen.stdout.close()
return_code = popen.wait()
if return_code:
raise sp.CalledProcessError(return_code, cmd)
for path in execute(["mvn", "exec:java" ,'-D"exec.mainClass"="org.matsim.project.MatsimRun"']):
print(path, end="")
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
[错误] 没有为此构建指定目标。您必须以 : 或 :[:]: 格式指定有效的生命周期阶段或目标。可用的生命周期阶段有:验证、初始化、生成源、处理源、生成资源、处理资源、编译、处理类、生成测试源、处理测试源、生成测试资源、处理-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify`
为什么会这样?可能有什么问题?
两种情况(终端、python 脚本)发生的警告相同。