2009-09-08 9 views
8

私の現在のプロジェクトでは、properties-maven-pluginやbuildnumber-pluginのような他のプラグインのパラメータに必要なプラグインをいくつか使用しています。プラグインのゴールを別のプラグインゴールにバインドする方法

<?xml version="1.0"?> 
<project> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>mygroup</groupId> 
    <artifactId>myartifact</artifactId> 
    <packaging>pom</packaging> 
    <version>v0</version> 
    <name>myProject</name> 

    <properties> 
      <env>dev</env> 
    </properties> 

    <build> 
     <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>properties-maven-plugin</artifactId> 
      <version>1.0-alpha-2</version> 
      <configuration> 
      <files> 
       <file>${basedir}/configurations/${env}.properties</file> 
      </files> 
      </configuration> 
      <executions> 
       <execution> 
        <phase>initialize</phase> 
        <goals> 
         <goal>read-project-properties</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>buildnumber-maven-plugin</artifactId> 
      <version>1.0-beta-3</version> 
      <executions> 
       <execution> 
        <phase>initialize</phase> 
        <goals> 
         <goal>create</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>com.wakaleo.schemaspy</groupId> 
      <artifactId>maven-schemaspy-plugin</artifactId> 
      <version>1.0</version> 
      <configuration> 
       <databaseType>mysql</databaseType> 
       <database>${database.schema}</database> 
       <host>${database.host}</host> 
       <user>${database.user}</user> 
       <password>${database.pwd}</password> 
       </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

問題は、プラグインゴールを直接実行すると、初期化フェーズでバインドされた目標(または検証)が実行されないということです。

$> mvn schemaspy:schemaspy 

があります:

$> mvn org.codehaus.mojo:properties-maven-plugin:read-project-properties schemaspy:schemaspy 

私たちは、プロパティがプラグインとBuildNumberをプラグインは、私たちが入力でき、すべてのmavenコマンドで実行する必要があることをお伝えしたいと思います。だから、スキーマのスパイを生成するために、我々は、入力する必要がありますそれを行うためのきれいな方法(スクリプトなし)?

答えて

6

ので、あなたは、単にMVNパッケージのようなものを実行して、すべての3つのプラグインを持つことができる、(あなたはすでに、他の2つのプラグインfforこれを行っている、特にとして)ライフサイクル・フェーズにschemaspy目標をバインドするだろう最も簡単な方法適切な段階で実行されます。

特定の状況でのみschmespyプラグインを実行する場合は、プロファイルに入れてからmvnパッケージ-P schemaspyを実行してアクティブにします。これを実現する設定は、次のようになります。

<profiles> 
    <profile> 
    <id>schemaspy</id> 
    <plugin> 
     <groupId>com.wakaleo.schemaspy</groupId> 
     <artifactId>maven-schemaspy-plugin</artifactId> 
     <version>1.0</version> 
     <executions> 
     <execution> 
      <phase>package</phase> 
      <goals> 
      <goal>schemaspy</goal> 
      </goals> 
     </execution> 
     </executions> 
     <configuration> 
     <databaseType>mysql</databaseType> 
     <database>${database.schema}</database> 
     <host>${database.host}</host> 
     <user>${database.user}</user> 
     <password>${database.pwd}</password> 
     </configuration> 
    </plugin> 
    </profile> 
</profile> 
+0

これは決して考えませんでした。私はそれが好きです。おかげさまで – noirbizarre

+3

申し訳ありませんが、これは私を助けません。目標を別の目標に結び付けることはできますか?私は、リリースのためにブランチのコンテキストでプラグインを使用してブランチ名を計算する必要があります。開発者にプロファイルを有効にし、通常は単に 'release:branch'を実行するときに、ブランチを作成するためのライフサイクルフェーズを実行するように頼むのは奇妙です。 –

関連する問題