第1章 Eclipse Vert.x を使用するためのアプリケーションの設定

Eclipse Vert.x を使用するようにアプリケーションを設定する場合は、アプリケーションのルートディレクトリーにある pom.xml ファイルの Eclipse Vert. x BOM(Bill of Materials)アーティファクトを参照する必要があります。BOM は、アーティファクトの正しいバージョンを設定するために使用されます。

要件

  • Maven ベースのアプリケーション

手順

  1. Pom .xml ファイルを開き、io .vertx:vertx-dependencies アーティファクトを <dependencyManagement> セクションに追加します。Type を pom として指定し、scopeimport として指定します。

    <project>
      ...
      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-dependencies</artifactId>
            <version>${vertx.version}</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
        </dependencies>
      </dependencyManagement>
      ...
    </project>
  2. 以下のプロパティーを追加して、使用している Eclipse Vert.x および Eclipse Vert.x Maven Plugin のバージョンを追跡します。

    プロパティーを使用して、リリースごとに変更する値を設定できます。たとえば、product または plugins のバージョンなどです。

    <project>
      ...
      <properties>
        <vertx.version>${vertx.version}</vertx.version>
        <vertx-maven-plugin.version>${vertx-maven-plugin.version}</vertx-maven-plugin.version>
      </properties>
      ...
    </project>
  3. アプリケーションのパッケージ化に使用されるプラグインとして vertx-maven-plugin を指定します。

    <project>
      ...
      <build>
        <plugins>
            ...
            <plugin>
                <groupId>io.reactiverse</groupId>
                <artifactId>vertx-maven-plugin</artifactId>
                <version>${vertx-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>vmp</id>
                        <goals>
                            <goal>initialize</goal>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <redeploy>true</redeploy>
                </configuration>
            </plugin>
            ...
        </plugins>
      </build>
      ...
    </project>
  4. Repositories および pluginRepositories を追加して、アプリケーションのビルド用のアーティファクトおよびプラグインが含まれるリポジトリーを指定します。

    <project>
    ...
      <repositories>
        <repository>
          <id>redhat-ga</id>
          <name>Red Hat GA Repository</name>
          <url>https://maven.repository.redhat.com/ga/</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>redhat-ga</id>
          <name>Red Hat GA Repository</name>
          <url>https://maven.repository.redhat.com/ga/</url>
        </pluginRepository>
      </pluginRepositories>
    ...
    </project>

関連情報

  • Eclipse Vert.x アプリケーションのパッケージ化に関する詳細は、Vert.x Maven Plugin のドキュメントを参照してください。