1

Java リソース ファイルに追加のテキストを書き込みたい (2 つの .java ファイルを 1 つに結合する)。そのための Python スクリプトを作成します。

また、Maven を使用して手順 (ファイルの結合、コンパイル、パッケージ化) を自動化したいと考えています。私はMavenの初心者ですがexec-maven-plugin、Pythonスクリプトを実行できることがわかりました。

<phase>process-resources</phase>コンパイル前に起動するように設定しようとしたのですが、Eclipse が文句を言いました。Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (execution: default, phase: process-resources)

以下は私のexec-maven-pluginのpomです:

  <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
            <execution>
                <phase>process-resources</phase> <!-- Eclipse complains an error here -->
                <goals>
                    <goal>exec</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <executable>python</executable>
            <workingDirectory>src/main/python</workingDirectory>
            <arguments>
                <argument>combine.py</argument>
            </arguments> 
        </configuration>
    </plugin>

この目的をどのように実装できるか知っている人はいますか? どうもありがとう。

4

2 に答える 2

3

これは Eclipse M2e プラグインのトリックです。Sachin Shekhar Rは正しいですが、私のような初心者には答えが十分に明確ではありません。ここに私の理解があります:

http://wiki.eclipse.org/M2E_plugin_execution_not_coveredを参照してください。
Eclipse M2e でこれを行うには 2 つの方法があります。

  1. Sachin Shekhar Rの回答に記載されているコードを使用してください。このコードは の下<pluginManagement><plugins>にあり、 の<pluginManagement>中にある必要があることに注意してください<plugins>。サンプルコード:</p>

    <build>
    <plugins>
                <plugin>
                   <!-- plugins here-->
                </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.codehaus.mojo</groupId>
                                    <artifactId>exec-maven-plugin</artifactId>
                                    <versionRange>[1.2.1,)</versionRange>
                                    <goals>
                                        <goal>exec</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore/>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    </build>
    

    これはプロジェクトでのみ機能します。

  2. Eclipse M2e プラグインの「クイック フィックス」機能を使用します。バージョン 1.0 以降に存在します。タブでエラーを見つけProblemsます。それを右クリックして、「クイック修正」を選択します。Quick Fix ウィンドウがポップアップするので、2 番目のオプションを選択しますMark goal exec as ignored in Eclipse build in Eclipse references (experimental)。このメソッドは、ライフサイクルマッピングのワークスペースプロファイルに
    上記のコードを書き込みます これはワークスペース全体で機能します<lifecycleMappingMetadata>workspace/.metadata/.plugins/org.eclipse.m2e.core/lifecycle-mapping-metadata.xml

于 2012-11-29T07:30:15.377 に答える