9

私の現在のプロジェクトでは、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 org.codehaus.mojo:properties-maven-plugin:read-project-properties schemaspy:schemaspy

次のように入力できるように、すべての maven コマンドに対してプロパティ プラグインと buildNumber プラグインを実行する必要があることを伝えたいと思います。

$> mvn schemaspy:schemaspy

(スクリプトなしで)それを行うためのきれいな方法はありますか?

4

1 に答える 1

6

最も簡単な方法は、schemaspy目標をライフサイクル フェーズにバインドすることです (特に、他の 2 つのプラグインに対して既にこれを行っている場合)。そのため、mvn パッケージなどを実行するだけで、3 つのプラグインすべてを適切なフェーズで実行できます。

特定の状況下でのみ schmespy プラグインを実行したい場合は、それをプロファイルに入れてから、mvn package -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>
于 2009-09-08T12:34:15.897 に答える