5.2. Maven プラグインを使用した OptaPlanner Red Hat ビルドの Quarkus Maven プロジェクトの作成


Apache Maven および Quarkus Maven プラグインを使用して、OptaPlanner および Quarkus アプリケーションを起動して実行できます。

前提条件

  • OpenJDK 11 以降がインストールされている。Red Hat ビルドの Open JDK は Red Hat カスマーポータル (ログインが必要) の ソフトウェアダウンロード ページから入手できます。
  • Apache Maven 3.8 以降がインストールされている。Maven は Apache Maven Project の Web サイトから入手できます。

手順

  1. コマンドターミナルで以下のコマンドを実行して、Maven が JDK 11 を使用し、Maven のバージョンが 3.8 以降であることを確認します。

    mvn --version
  2. 上記のコマンドで JDK 11 が返されない場合は、JDK 11 へのパスを PATH 環境変数に追加し、上記のコマンドを再度入力します。
  3. Quarkus OptaPlanner クイックスタートプロジェクトを生成するには、以下のコマンドを入力します。

    mvn com.redhat.quarkus.platform:quarkus-maven-plugin:2.7.6.Final-redhat-00006:create \
        -DprojectGroupId=com.example \
        -DprojectArtifactId=optaplanner-quickstart  \
        -Dextensions="resteasy,resteasy-jackson,optaplanner-quarkus,optaplanner-quarkus-jackson" \
        -DplatformGroupId=com.redhat.quarkus.platform
        -DplatformVersion=2.7.6.Final-redhat-00006 \
        -DnoExamples

    このコマンドは、./optaplanner-quickstart ディレクトリーで以下の要素を作成します。

    • Maven の構造
    • src/main/dockerDockerfile ファイルの例
    • アプリケーションの設定ファイル

      表5.1 mvn io.quarkus:quarkus-maven-plugin:2.7.6.Final-redhat-00006:create コマンドで使用したプロパティー
      プロパティー説明

      projectGroupId

      プロジェクトのグループ ID。

      projectArtifactId

      プロジェクトのアーティファクト ID。

      extensions

      このプロジェクトで使用する Quarkus 拡張のコンマ区切りリスト。Quarkus 拡張の全一覧については、特定のコマンドラインで mvn quarkus:list-extensions を入力します。

      noExamples

      テストまたはクラスを使用せずに、プロジェクト構造でプロジェクトを作成します。

      projectGroupID および projectArtifactID プロパティーの値を使用して、プロジェクトバージョンを生成します。デフォルトのプロジェクトバージョンは 1.0.0-SNAPSHOT です。

  4. OptaPlanner プロジェクトを表示するには、OptaPlanner Quickstarts ディレクトリーに移動します。

    cd optaplanner-quickstart
  5. pom.xml ファイルを確認します。コンテンツの例を以下に示します。

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.example</groupId>
     <artifactId>optaplanner-quickstart</artifactId>
     <version>1.0.0-SNAPSHOT</version>
     <properties>
      <compiler-plugin.version>3.8.1</compiler-plugin.version>
      <failsafe.useModulePath>false</failsafe.useModulePath>
      <maven.compiler.release>11</maven.compiler.release>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
      <quarkus.platform.group-id>com.redhat.quarkus.platform</quarkus.platform.group-id>
      <quarkus.platform.version>2.7.6.Final-redhat-00006</quarkus.platform.version>
      <surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
     </properties>
    <dependencyManagement>
     <dependencies>
      <dependency>
       <groupId>${quarkus.platform.group-id}</groupId>
       <artifactId>${quarkus.platform.artifact-id}</artifactId>
       <version>${quarkus.platform.version}</version>
       <type>pom</type>
       <scope>import</scope>
      </dependency>
      <dependency>
       <groupId>io.quarkus.platform</groupId>
       <artifactId>quarkus-optaplanner-bom</artifactId>
       <version>2.7.6.Final</version>
       <type>pom</type>
       <scope>import</scope>
      </dependency>
     </dependencies>
    </dependencyManagement>
     <dependencies>
      <dependency>
       <groupId>org.optaplanner</groupId>
       <artifactId>optaplanner-quarkus</artifactId>
      </dependency>
      <dependency>
       <groupId>org.optaplanner</groupId>
       <artifactId>optaplanner-quarkus-jackson</artifactId>
      </dependency>
      <dependency>
       <groupId>io.quarkus</groupId>
       <artifactId>quarkus-resteasy-jackson</artifactId>
      </dependency>
      <dependency>
       <groupId>io.quarkus</groupId>
       <artifactId>quarkus-resteasy</artifactId>
      </dependency>
      <dependency>
       <groupId>io.quarkus</groupId>
       <artifactId>quarkus-arc</artifactId>
      </dependency>
      <dependency>
       <groupId>io.quarkus</groupId>
       <artifactId>quarkus-junit5</artifactId>
       <scope>test</scope>
      </dependency>
      <dependency>
       <groupId>io.rest-assured</groupId>
       <artifactId>rest-assured</artifactId>
       <scope>test</scope>
      </dependency>
     </dependencies>
     <repositories>
      <repository>
       <releases>
        <enabled>true</enabled>
       </releases>
       <snapshots>
        <enabled>false</enabled>
       </snapshots>
       <id>redhat</id>
       <url>https://maven.repository.redhat.com/ga</url>
      </repository>
     </repositories>
    <pluginRepositories>
     <pluginRepository>
      <releases>
       <enabled>true</enabled>
      </releases>
      <snapshots>
       <enabled>false</enabled>
      </snapshots>
      <id>redhat</id>
      <url>https://maven.repository.redhat.com/ga</url>
     </pluginRepository>
    </pluginRepositories>
    <build>
     <plugins>
      <plugin>
       <groupId>${quarkus.platform.group-id}</groupId>
       <artifactId>quarkus-maven-plugin</artifactId>
       <version>${quarkus.platform.version}</version>
       <extensions>true</extensions>
      <executions>
       <execution>
        <goals>
         <goal>build</goal>
         <goal>generate-code</goal>
         <goal>generate-code-tests</goal>
        </goals>
       </execution>
      </executions>
     </plugin>
     <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>${compiler-plugin.version}</version>
      <configuration>
       <compilerArgs>
        <arg>-parameters</arg>
       </compilerArgs>
      </configuration>
     </plugin>
     <plugin>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>${surefire-plugin.version}</version>
      <configuration>
       <systemPropertyVariables>
        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
        <maven.home>${maven.home}</maven.home>
       </systemPropertyVariables>
      </configuration>
     </plugin>
     </plugins>
      </build>
       <profiles>
        <profile>
         <id>native</id>
        <activation>
         <property>
           <name>native</name>
         </property>
        </activation>
        <build>
         <plugins>
          <plugin>
           <artifactId>maven-failsafe-plugin</artifactId>
           <version>${surefire-plugin.version}</version>
           <executions>
            <execution>
             <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
             </goals>
             <configuration>
              <systemPropertyVariables>
               <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
               <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
               <maven.home>${maven.home}</maven.home>
              </systemPropertyVariables>
             </configuration>
            </execution>
           </executions>
          </plugin>
         </plugins>
        </build>
       <properties>
        <quarkus.package.type>native</quarkus.package.type>
       </properties>
      </profile>
     </profiles>
    </project>
Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.