【发布时间】:2012-12-08 02:34:37
【问题描述】:
我在 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 变量中。
如何修复它以使其独立于操作系统平台工作?
.:-EDIT-:.
工作代码片段
<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>
【问题讨论】:
-
问题是为什么需要运行python脚本?您需要在 Linux 上的 Windows 上定义 python 解释器,shebang-line 很重要。
-
我使用你的方法在 maven 安装阶段运行了一个耗时的 python 脚本,python 脚本可以工作,但是使用混乱的控制台日志,来自 python 的输出是一些随机错误的顺序。你有同样的问题吗?
标签: maven python-2.7 exec-maven-plugin