0

さまざまなLinuxディストリビューションでディストリビューション固有のビルドを実行するためのカスタムエンフォーサールールを作成してテストしました。提供されているビルドスニペットを使用して、mvn enforcer:enforceコマンドで適切にテストします。pom.xml

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>1.0-beta-1</version>
    <dependencies>
      <dependency>
        <groupId>org.example</groupId>
        <artifactId>maven-enforcer-rule-redhat6x</artifactId>
        <version>1.0</version>
      </dependency>
    </dependencies>
    <configuration>
      <rules>
        <redhat6x implementation="org.example.enforcer.Redhat6x">
          <compatible>true</compatible>
        </redhat6x>
      </rules>
    </configuration>
    <executions>
      <execution>
        <id>enforce</id>
      </execution>
    </executions>
    <goals>
      <goal>enforce</goal>
    </goals>
  </plugin>
</plugins>

頭を悩ませて多くの実験的なテストを行った後、このカスタムエンフォーサールールをプロファイルアクティベーションセレクターとして使用する方法が見つからないようです。

  <profiles>
    <profile>
      <id>RedHat6x</id>
      <activation>
      <!-- Something goes here, but what?  This doesn't work -->
            <redhat6x implementation="com.cisco.tesdw.enforcer.Redhat6x">
              <compatible>true</compatible>
            </redhat6x>
      </activation>
    </profile>
  </profiles>

「プロファイルの概要」ページの「ビルド中にどのプロファイルが有効であるかを確認するにはどうすればよいですか」セクションでmaven-enforcer-rules詳しく説明されているように、プロファイルのアクティブ化で使用されるヒントがいくつかあります。つまり、複数の文字列値(os nameなど)を持つすべてのプロファイルアクティベーションは、対応するMavenエンフォーサールールを参照します。ただし、カスタムプロファイルアクティベーターをpom.xmlに直接含めることは明らかではないようであり、そのようなものを追加するには、pomバージョンの更新が必要になる可能性があります

Maven3は非常に柔軟な方法で拡張可能ですが、Maven拡張メカニズムによってエンフォーサールールの包含をフックすることは可能ですか?カスタムライフサイクル参加者を含める方法に関するドキュメントがあります。ただし、ビルドが開始されるまでに、プロファイルのアクティブ化がすでに行われている可能性があります。ドキュメントはまばらですが、javadocは、AbstractMavenLifecycleParticipant.afterProjectsRead(MavenSession session)「すべてのMavenProjectインスタンスが作成された後」と呼ばれることを示しています。これは、それが呼び出されるのがプロファイルのアクティブ化の前か後かという疑問を私に残します。私は後で疑っています、またはどのように適切に構成されますMavenProjectか?

プロファイルアクティベーションのカスタマイズがリモートでも可能かどうか誰かに教えてもらえますか?

4

1 に答える 1

1

プロファイルの下でプラグイン構成を移動する必要があります。

<profiles>
    <profile>
      <id>RedHat6x</id>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>1.0-beta-1</version>
          <dependencies>
            <dependency>
              <groupId>org.example</groupId>
              <artifactId>maven-enforcer-rule-redhat6x</artifactId>
              <version>1.0</version>
            </dependency>
          </dependencies>
          <configuration>
            <rules>
              <redhat6x implementation="org.example.enforcer.Redhat6x">
                <compatible>true</compatible>
              </redhat6x>
            </rules>
          </configuration>
          <executions>
            <execution>
              <id>redhat-enforce</id>
            </execution>
          </executions>
          <goals>
            <goal>enforce</goal>
          </goals>
        </plugin>
      </plugins>
    </profile>
</profiles>
于 2012-03-26T17:33:05.480 に答える