16

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 変数に追加しました。

OS プラットフォームに関係なく動作するように修正するにはどうすればよいですか?

。:-編集-:。

ワーキングコードスニペット

<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>
4

2 に答える 2

17

Windows では、スクリプトは実行できません。実行可能ファイルは python インタープリターであり、スクリプトはその引数であるため<executable>path to your python interpreter</executable>、スクリプトを<argument>. 同じことがどのプラットフォームでも機能するはずですが、私は Python の専門家ではありません。

于 2012-12-24T17:36:13.590 に答える