1

exec-maven-plugin を使用して、maven でバッチ ファイルを実行しています。パッケージ段階で実行していましたが、それよりも早く実行する必要があります。コンパイル段階は問題ありません。

バッチ スクリプトは、svn バージョンを含むプロパティ ファイルを生成します。フェーズがパッケージに設定されている場合、war ファイルを作成したにこれを行うように見えます。私には遅すぎる。

ただし、Eclipseでは次のエラーが発生します。

Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (execution: Version, phase: compile)

私の pom.xml の関連セクション:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.2.1</version>
  <executions>
     <execution>
        <id>Version</id>
        <phase>compile</phase>
        <goals>
           <goal>exec</goal>
        </goals>
     </execution>
  </executions>
  <configuration>
     <executable>\my\path\version\version.bat</executable>
  </configuration>
</plugin>

まず、exec-maven-plugin は今でも適切なツールですか?

第二に、パッケージよりも早い段階で実行できますか? これはどこかに文書化されていますか?exec-maven-plugin プロジェクト ページのメーリング リスト アーカイブ リンクは古くなっています。

4

1 に答える 1

1

問題はプラグインではexec-maven-pluginなくm2e、何をすべきかわからないプラグインにありますexec-maven-pluginこの問題を解決する最も簡単な方法は、 Eclipse 内でのビルド中にそのプラグインを無視することです(問題を右クリックし、提案された解決策を使用してください)。コマンド ライン呼び出しでは、引き続きバッチが実行されます。

必要に応じm2eて、より洗練された構成が可能です。私のプロジェクトの 1 つのスニペットを見てください。

<pluginManagement>
  <plugins>
    ...
    <!-- The following plugin is solely to make Eclipse happy, it's not executed during regular build -->
    <plugin>
      <groupId>org.eclipse.m2e</groupId>
      <artifactId>lifecycle-mapping</artifactId>
      <version>1.0.0</version>
      <configuration>
        <lifecycleMappingMetadata>
          <pluginExecutions>
            <pluginExecution>
              <pluginExecutionFilter>
                <groupId>com.googlecode.cmake-maven-project</groupId>
                <artifactId>cmake-maven-plugin</artifactId>
                <versionRange>[2.8.11-b4-SNAPSHOT,)</versionRange>
                <goals>
                  <goal>generate</goal>
                  <goal>compile</goal>
                </goals>
              </pluginExecutionFilter>
              <action>
                <execute />
              </action>
            </pluginExecution>
          </pluginExecutions>
        </lifecycleMappingMetadata>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>

また、任意のフェーズで実質的に任意のプラグインのすべてのゴールを実行するか、その実行を完全に無効にすることができます。ここでは、 を無効default-deployにしてmaven-deploy-plugin、カスタマイズされた目標deploy-filedeployフェーズに割り当てます。

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-deploy-plugin</artifactId>
      <version>2.5</version>
      <executions>
        <execution>
          <id>default-deploy</id>
          <phase>none</phase>
        </execution>
        <execution>
          <id>versioned-deploy</id>
          <goals>
            <goal>deploy-file</goal>
          </goals>
          <phase>deploy</phase>
          <configuration>
            <file>${project.build.directory}/${project.build.finalName}.${project.packaging}</file>
            <repositoryId>${project.distributionManagement.repository.id}</repositoryId>
            <url>${project.distributionManagement.repository.url}</url>
            <generatePom>false</generatePom>
            <pomFile>${effective_dir}/pom.xml</pomFile>
          </configuration>
        </execution>
      </executions>
    </plugin>

mvn help:effective-pomMaven化されたプロジェクトの最終的な構成を理解できる特別なコマンドがあります。

于 2014-02-07T03:37:20.097 に答える