我在 Win 7 上使用 Maven 来构建应用程序。我使用 exec 插件来调用 python 脚本。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>create-dir</id>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>src/main/upgrade/create.py</executable>
<arguments>
<argument>ChangeSet.txt</argument>
</arguments>
</configuration>
</plugin>
当我构建项目时,我收到以下错误。
Embedded error: Cannot run program "pathToScript/create.py" CreateProcess error=193, %1 is not a valid Win32 application
我确实安装了 python 并将其添加到 %PATH 变量中。
如何修复它,使其独立于操作系统平台工作?
。:-编辑-:。
工作代码片段
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<executable>python</executable>
<workingDirectory>src/main/upgrade/</workingDirectory>
<arguments>
<argument>createChangeSet.py</argument>
</arguments>
</configuration>
<id>python-build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
在 Windows 中,该脚本不可执行。可执行文件是 python 解释器,脚本是它的参数,所以把<executable>path to your python interpreter</executable>
并将脚本添加为<argument>
。我希望同样的方法适用于任何平台,但我不是 Python 专家。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)