Maven を使用したアプリケーションのビルド
新規プロジェクトの作成
次のように新しいMavenプロジェクトの枠組を生成することができます。
CLIを使用している場合、次のように利用可能なオプションのリストを取得することが可能です。
quarkus create app --help
Maven コマンドを使用している場合、次の表が create
コマンドに渡すことができる属性の一覧です。
属性 | デフォルト値 | 説明 |
---|---|---|
|
|
作成されたプロジェクトのグループID |
|
mandatory |
作成されたプロジェクトのアーティファクトID。これを渡さないと、インタラクティブモードがトリガされます。 |
|
|
作成されたプロジェクトのバージョン |
|
|
ターゲットプラットフォームのグループID |
|
|
ターゲットプラットフォームBOMのアーティファクトID |
|
現在、 Quarkus Extension Registryで推奨されているバージョン |
プロジェクトで使用したいプラットフォームのバージョンを指定します。バージョンの範囲を指定することもでき、その場合は指定した範囲の最新のものが使用されます。 |
|
省略された場合は作成されない |
生成されたリソースの完全修飾名 |
|
|
リソースパス、 |
|
[] |
プロジェクトに追加するエクステンションのリスト (カンマ区切り) |
|
|
Whether Quarkus should use the online registry to resolve extension catalogs. If this is set to false, the extension catalog will be narrowed to the defined (or default) platform BOM. |
デフォルトでは、コマンドは io.quarkus.platform:quarkus-bom:2.11.1.Final
プラットフォームリリースをターゲットにします (目的のプラットフォームリリースの座標が指定されていない場合)。
プロジェクトは、渡された artifactId にちなんだ名前のディレクトリーに生成されます。ディレクトリーが既に存在する場合は、生成に失敗します。
ネイティブモードと jvm モード用の Dockerfile も src/main/docker
に生成されています。イメージのビルドとコンテナーの実行の指示は、これらの Dockerfile に書かれています。
エクステンションへの対応
Quarkusプロジェクトの内部から、利用可能なエクステンションのリストを取得することができます。
quarkus extension
./mvnw quarkus:list-extensions
以下を使ってエクステンションを追加できます。
quarkus extension add 'hibernate-validator'
./mvnw quarkus:add-extension -Dextensions="hibernate-validator"
エクステンションは、カンマ区切りのリストを使用して渡されます。
The extension name is the GAV name of the extension: e.g. io.quarkus:quarkus-agroal
. But you can pass a partial name and Quarkus will do its best to find the right extension. For example, agroal
, Agroal
or agro
will expand to io.quarkus:quarkus-agroal
. If no extension is found or if more than one extension matches, you will see a red check mark ❌ in the command result.
$ ./mvnw quarkus:add-extensions -Dextensions=jdbc,agroal,non-exist-ent
[...]
❌ Multiple extensions matching 'jdbc'
* io.quarkus:quarkus-jdbc-h2
* io.quarkus:quarkus-jdbc-mariadb
* io.quarkus:quarkus-jdbc-postgresql
Be more specific e.g using the exact name or the full gav.
✅ Adding extension io.quarkus:quarkus-agroal
❌ Cannot find a dependency matching 'non-exist-ent', maybe a typo?
[...]
グロブパターンに一致するすべてのエクステンションをインストールすることができます。
quarkus extension add 'smallrye-*'
./mvnw quarkus:add-extension -Dextensions="smallrye-*"
開発モード
Quarkusには開発モードが組み込まれています。以下でアプリケーションを実行します。
quarkus dev
./mvnw quarkus:dev
その後、アプリケーションのソース、リソース、および設定を更新することができます。変更は実行中のアプリケーションに自動的に反映されます。変更がすぐに反映されるので、UIやデータベースにまたがった開発をするのに最適です。
Devモードでは、バックグラウンド・コンパイルによるホット・デプロイメントが可能です。つまり、Javaファイルやリソース・ファイルを変更してブラウザを更新すると、その変更が自動的に反映されます。これは、Javaファイルやリソースファイルを変更してブラウザを更新すると、その変更が自動的に反映されることを意味します。ブラウザを更新すると、ワークスペースのスキャンが行われ、変更が検出されると、Javaファイルがコンパイルされ、アプリケーションが再デプロイされ、再デプロイされたアプリケーションによってリクエストが処理されます。コンパイルやデプロイに問題があった場合は、エラーページでお知らせします。
CTRL+C
を叩いてアプリケーションを停止させます。
デフォルトでは、 CLI
Maven
|
リモート開発モード
開発モードをリモートで使用することができるので、コンテナー環境(OpenShiftなど)でQuarkusを実行して、ローカルファイルに加えられた変更をすぐに確認できるようにすることができます。
これにより、実際にアプリを実行するのと同じ環境で、同じサービスにアクセスしながら開発することができます。
本番環境では使用しないでください。開発環境でのみ使用してください。本番環境のアプリケーションを開発モードで実行してはいけません。 |
これを行うには、 mutable-jar
形式を使用して、ミュータブルアプリケーションをビルドする必要があります。 application.properties
で以下のプロパティーを設定してください。
quarkus.package.type=mutable-jar (1)
quarkus.live-reload.password=changeit (2)
quarkus.live-reload.url=http://my.cluster.host.com:8080 (3)
1 | これは、QuarkusにMutable-jar形式を使用するように指示します。ミュータブルアプリケーションには、Quarkusのデプロイメント時の部分も含まれているため、より多くのディスクスペースを占有します。普通に実行した場合は、イミュータブルアプリケーションと同じ速度で起動し、同じメモリーを使用しますが、devモードで起動することもできます。 |
2 | リモート側とローカル側の通信を安全に保つためのパスワードです。 |
3 | アプリがdevモードで実行されるURL。これはローカル側でのみ必要なので、プロパティーファイルから除外して、コマンドラインでシステムプロパティーとして指定するとよいでしょう。 |
mutable-jar
は、通常のQuarkus jarをビルドするのと同じ方法で発行することでビルドされます。つまり以下のように発行できます:
quarkus build
./mvnw clean package
リモートホストでQuarkusを起動する前に、環境変数 QUARKUS_LAUNCH_DEVMODE=true
を設定します。ベアメタルを使用している場合は、 export QUARKUS_LAUNCH_DEVMODE=true
コマンドで設定し、適切に java -jar …
コマンドでアプリケーションを実行します。
アプリケーションをdocker経由で実行する場合は、docker run
コマンドに -e QUARKUS_LAUNCH_DEVMODE=true
を追加してイメージを起動します。アプリケーションが起動すると、ログに次のような行が表示されるはずです: Profile dev activated. Live Coding activated
.
The remote side does not need to include Maven or any other development tools. The normal fast-jar Dockerfile that is generated with a new Quarkus application is all you need. If you are using bare metal launch the Quarkus runner jar, do not attempt to run normal dev mode.
|
ここで、 remote-dev
コマンドを使用して、ローカルエージェントをリモートホストに接続する必要があります。
./mvnw quarkus:remote-dev -Dquarkus.live-reload.url=http://my-remote-host:8080
Now every time you refresh the browser you should see any changes you have made locally immediately visible in the remote app. This is done via an HTTP based long polling transport, that will synchronize your local workspace and the remote application via HTTP calls.
HTTP 機能を使用したくない場合は、URL を指定せずに remote-dev
コマンドを実行するだけです。このモードでは、コマンドはローカルアプリケーションを継続的に再ビルドするので、 odo や rsync のような外部ツールを使ってリモートアプリケーションに同期することができます。
全ての設定オプションは以下の通りです:
ビルド時に固定される設定プロパティ - それ以外の設定プロパティは実行時に上書き可能
タイプ |
デフォルト |
|
---|---|---|
Whether Quarkus should enable its ability to not do a full restart when changes to classes are compatible with JVM instrumentation. If this is set to true, Quarkus will perform class redefinition when possible. Environment variable: |
boolean |
|
The names of additional resource files to watch for changes, triggering a reload on change. Directories are not supported. Environment variable: |
list of string |
|
Password used to use to connect to the remote dev-mode application Environment variable: |
string |
|
URL used to use to connect to the remote dev-mode application Environment variable: |
string |
|
The amount of time to wait for a remote dev connect or reconnect Environment variable: |
|
|
The amount of time to wait between attempts when connecting to the server side of remote dev Environment variable: |
|
|
The maximum number of attempts when connecting to the server side of remote dev Environment variable: |
int |
|
期間フォーマットについて
期間のフォーマットは標準の 数値で始まる期間の値を指定することもできます。この場合、値が数値のみで構成されている場合、コンバーターは値を秒として扱います。そうでない場合は、 |
リモート開発モードを使用する際には SSL を使用することを推奨しますが、たとえ暗号化されていない接続を使用していても、パスワードが直接ネットワーク上で送信されることはありません。最初の接続リクエストでは、パスワードは初期状態のデータでハッシュ化され、それ以降のリクエストでは、サーバーによって生成されたランダムなセッションIDと、POSTリクエストのためのボディコンテンツ、DELETEリクエストのためのパス、そしてリプレイ攻撃を防ぐためのインクリメントカウンタでハッシュ化されます。 |
開発モードの設定
デフォルトでは、Maven プラグインは maven-compiler-plugin
から javac
に渡すコンパイラフラグをピックアップします。
開発モードで使用するコンパイラ・フラグをカスタマイズする必要がある場合は、 plugin
ブロックに configuration
セクションを追加し、 maven-compiler-plugin
を設定するときと同じように compilerArgs
プロパティーを設定します。また、 source
、 target
、および jvmArgs
を設定することもできます。例えば、 --enable-preview
を JVM と javac
の両方に渡すには、 を設定します。
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
<jvmArgs>--enable-preview</jvmArgs>
</configuration>
...
</plugin>
デバッグ
開発モードでは、Quarkusはデフォルトでデバッグモードを有効にして起動し、JVMをサスペンドせずにポート 5005
をリッスンします。
この動作は、 debug
システム・プロパティーに以下の値のいずれかを与えることで変更できます。
-
false
- JVM はデバッグモードを無効にして起動します。 -
true
- JVM はデバッグモードで起動され、5005
ポートをリッスンします。 -
client
- JVM はクライアントモードで起動し、localhost:5005
に接続を試みます。 -
{port}
- JVM はデバッグモードで開始され、{port}
でリッスンします
追加のシステム・プロパティー suspend
は、デバッグ・モードで起動されたときに JVM をサスペンドするために使用できます。suspend
は以下の値をサポートしています。
-
y
またはtrue
- デバッグモードの JVM 起動が中断されます。 -
n
またはfalse
- デバッグモードの JVM をサスペンドせずに起動します。
また、JVM をサスペンドした状態で、デバッグモードで Quarkus アプリケーションを実行することもできます。 CLI
Maven
次に、デバッガーを |
IDEへのインポート
プロジェクトを生成 したら、お気に入りの IDE にインポートすることができます。唯一の要件は、Maven プロジェクトをインポートできることです。
Eclipse
Eclipse で、File → Import
をクリックします。ウィザードで、Maven → Existing Maven Project
を選択します。次の画面で、プロジェクトの root の場所を選択します。次の画面では、見つかったモジュールのリストが表示されるので、生成されたプロジェクトを選択して Finish
をクリックします。これで完了です!
別のターミナルで、以下を実行します。
quarkus dev
./mvnw quarkus:dev
では、生産性の高い環境を楽しんで下さい。
IntelliJ IDEA
In IntelliJ IDEA:
-
From inside IntelliJ IDEA select
File → New → Project From Existing Sources…
or, if you are on the welcome dialog, selectImport project
. -
プロジェクトの root を選択します。
-
Import project from external model
およびMaven
を選択します。 -
Next を数回クリックします (必要に応じてさまざまなオプションを確認してください)。
-
最後の画面で Finish をクリックします。
別のターミナルや組込ターミナルで、以下を実行します。
quarkus dev
./mvnw quarkus:dev
楽しんでください!
Apache NetBeans
NetBeans の場合:
-
File → Open Project
を選択 -
プロジェクトの root を選択します。
-
Open Project
をクリックしてください。
別のターミナルまたは組込ターミナルで、プロジェクトのルートに移動して次を実行します。
quarkus dev
./mvnw quarkus:dev
楽しんでください!
Visual Studio Code
VS Codeでプロジェクトディレクトリーを開きます。Java Extension Pack (Javaエクステンションのセットをグループ化したもの) をインストールしている場合、プロジェクトは Maven プロジェクトとしてロードされます。
Quarkus アプリケーションのビルドクラスパスツリーのロギング
通常、アプリケーション(Mavenプロジェクト)の依存関係は、 mvn dependency:tree
コマンドを使用して表示することができます。しかし、Quarkusアプリケーションの場合、このコマンドはアプリケーションの実行時の依存関係のみを表示します。Quarkusのビルドプロセスは、アプリケーションで使用されているエクステンションのデプロイメント依存関係を元のアプリケーションのクラスパスに追加するので、どの依存関係とどのバージョンがビルドクラスパスで終わるかを知ることは便利です。幸いにも、 quarkus-bootstrap
Mavenプラグインには、アプリケーションのビルド依存関係ツリーを表示する build-tree
ゴールが含まれています。
プロジェクトで ./mvnw quarkus:dependency-tree
を実行すると、次のような出力が得られるはずです。
[INFO] --- quarkus-maven-plugin:2.11.1.Final:dependency-tree (default-cli) @ getting-started ---
[INFO] org.acme:getting-started:jar:1.0.0-SNAPSHOT
[INFO] └─ io.quarkus:quarkus-resteasy-deployment:jar:2.11.1.Final (compile)
[INFO] ├─ io.quarkus:quarkus-resteasy-server-common-deployment:jar:2.11.1.Final (compile)
[INFO] │ ├─ io.quarkus:quarkus-core-deployment:jar:2.11.1.Final (compile)
[INFO] │ │ ├─ commons-beanutils:commons-beanutils:jar:1.9.3 (compile)
[INFO] │ │ │ ├─ commons-logging:commons-logging:jar:1.2 (compile)
[INFO] │ │ │ └─ commons-collections:commons-collections:jar:3.2.2 (compile)
...
ゴールは、以下のオプションのパラメーターを受け入れます。
-
mode
- デフォルト値はprod
で、本番ビルドの依存関係ツリーを表示します。または、値test
を受け入れてテスト依存関係ツリーを表示し、dev
を受け入れて開発モードの依存関係ツリーを表示します。 -
outputFile
- 依存関係ツリーを永続化するファイルを指定します。 -
appendOutput
- the default value isfalse
, indicates whether the output to the command should be appended to the file specified with theoutputFile
parameter or it should be overridden.
オフライン開発とテスト向けの Maven アーティファクトの依存関係のダウンロード
Quarkus エクステンションの依存関係は、アプリケーションの実行時クラスパスに到達する実行時エクステンションの依存関係と、アプリケーションのビルド時にのみ Quarkus によって解決されてビルドクラスパスを作成するデプロイメント (またはビルド時) のエクステンションの依存関係に分けられます。アプリケーション開発者は、Quarkus エクステンションのランタイムアーティファクトにのみ依存関係を表現することが期待されています。結果として、デプロイメントエクステンションの依存関係は、Quarkus エクステンションの依存関係モデル (maven-dependency-plugin
、go-offline-maven-plugin
など) を認識しない Maven プラグインには表示されません。つまり、これらのプラグインを使用してすべてのアプリケーションの依存関係を事前にダウンロードして、後でオフラインモードでアプリケーションをビルドおよびテストできるようにすることはできません。
Quarkus アプリケーションをオフラインでビルドおよびテストするユースケースを有効にするために、quarkus-maven-plugin
には、以下のようにコマンドラインから呼び出すことができる go-offline
ゴールが含まれています。
./mvnw quarkus:go-offline
このゴールは、アプリケーションの実行時、ビルド時、テスト、および開発モードのすべての依存関係を解決し、これらを設定されたローカルの Maven リポジトリーにダウンロードします。
ネイティブ実行可能ファイルのビルド
ネイティブ実行可能ファイルにより、Quarkusアプリケーションはコンテナーやサーバーレスのワークロードに最適です。
GRAALVM_HOME
が設定され、GraalVM バージョン 22.1 を指していることを確認してください (必ず Java 11 バージョンの GraalVM を使用してください)。pom.xml
に適切な native
プロファイルがあることを確認します (Maven 設定 を参照してください)。
次のようにネイティブ実行可能ファイルの作成
quarkus build --native
./mvnw package -Dnative
ネイティブ実行可能ファイルが target/
に存在します。
ネイティブ実行可能ファイルで統合テストを実行するには、適切な Maven プラグインが設定されていることを確認し (Maven 設定 を参照)、verify
ゴールを起動します。
$ ./mvnw verify -Pnative
...
[quarkus-quickstart-runner:50955] universe: 391.96 ms
[quarkus-quickstart-runner:50955] (parse): 904.37 ms
[quarkus-quickstart-runner:50955] (inline): 1,143.32 ms
[quarkus-quickstart-runner:50955] (compile): 6,228.44 ms
[quarkus-quickstart-runner:50955] compile: 9,130.58 ms
[quarkus-quickstart-runner:50955] image: 2,101.42 ms
[quarkus-quickstart-runner:50955] write: 803.18 ms
[quarkus-quickstart-runner:50955] [total]: 33,520.15 ms
[INFO]
[INFO] --- maven-failsafe-plugin:2.22.0:integration-test (default) @ quarkus-quickstart-native ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.acme.quickstart.GreetingResourceIT
Executing [/Users/starksm/Dev/JBoss/Quarkus/starksm64-quarkus-quickstarts/getting-started-native/target/quarkus-quickstart-runner, -Dquarkus.http.port=8081, -Dtest.url=http://localhost:8081, -Dquarkus.log.file.path=target/quarkus.log]
2019-02-28 16:52:42,020 INFO [io.quarkus] (main) Quarkus started in 0.007s. Listening on: http://localhost:8080
2019-02-28 16:52:42,021 INFO [io.quarkus] (main) Installed features: [cdi, resteasy-reactive]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.081 s - in org.acme.quickstart.GreetingResourceIT
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
...
コンテナーフレンドリーな実行ファイルをビルドする
ネイティブ実行可能ファイルは、お使いのオペレーティングシステムに固有のものになります。コンテナー内で実行される実行ファイルを作成するには、次のようにします。
quarkus build --native -Dquarkus.native.container-build=true
./mvnw package -Dnative -Dquarkus.native.container-build=true
The produced executable will be a 64-bit Linux executable, so depending on your operating system it may no longer be runnable. However, it’s not an issue as we are going to copy it to a Docker container. Note that in this case the build itself runs in a Docker container too, so you don’t need to have GraalVM installed locally.
デフォルトでは、ネイティブ実行可能ファイルは、 異なる Docker イメージでネイティブ実行可能ファイルをビルドしたい場合 (たとえば、異なる GraalVM バージョンを使用する場合など) は、 利用可能なDockerイメージのリストは、 quay.ioにあります。特定のQuarkusのバージョンは、利用可能なすべてのイメージと互換性がない場合があることに注意してください。 |
Maven 設定
project scaffolding を使用したことがない場合は、pom.xml
に以下の要素を追加してください。
<properties>
<skipITs>true</skipITs> (1)
</properties>
<dependencyManagement>
<dependencies>
<dependency> (2)
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-bom</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin> (3)
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions> (4)
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin> (5)
<groupId>org.apache.maven.plugins</groupId>
<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>
<plugin> (6)
<groupId>org.apache.maven.plugins</groupId>
<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>
<profiles>
<profile> (7)
<id>native</id>
<properties> (8)
<quarkus.package.type>native</quarkus.package.type>
<skipITs>false</skipITs> (9)
</properties>
</profile>
</profiles>
1 | Disable running of integration tests (test names *IT and annotated with @QuarkusIntegrationTest ) on all builds. To run these tests all the time, either remove this property, set its value to false , or set -DskipITs=false on the command line when you run the build. + As mentioned below, this is overridden in the native profile. |
2 | オプションで、BOMファイルを使用して、異なるQuarkus依存関係のバージョンを省略することができます。 |
3 | ビルドプロセスにフックするQuarkus Mavenプラグインを使用します。 |
4 | Mavenプラグインのエクステンションを有効にすると、Quarkus MavenLifecycleParticipant が登録され、ビルド中に使用されるQuarkusクラスローダが適切にクローズされるようになります。 generate-code と generate-code-tests のゴールでは、Quarkusアプリケーションブートストラップが初期化され、 build のゴール(本番アプリケーションを実際にビルドしてパッケージ化する)で再利用されます。 quarkus-maven-plugin の build ゴールでは、Quarkus のクラスローダが適切にクローズされます。しかし、 generate-code または generate-code-tests と build の間でビルドが失敗すると、Quarkus augmentation classloaderは適切に閉じられず、Windows OSのクラスパス上にたまたまあったJARファイルがロックされる可能性があります。 |
5 | システムプロパティーを maven-surefire-plugin に追加します。maven.home は、${maven.home}/conf/settings.xml にカスタム設定がある場合にのみ必要です。 |
6 | If you want to test the artifact produced by your build with Integration Tests, add the following plugin configuration. Test names *IT and annotated with @QuarkusIntegrationTest will be run against the artifact produced by the build (JAR file, container image, etc). See the Integration Testing guide for more info. + maven.home is only required if you have custom configuration in ${maven.home}/conf/settings.xml . |
7 | ネイティブ実行可能ファイルのビルドには、特定の native プロファイルを使用します。 |
8 | native パッケージタイプを有効にします。そのため、ビルドはネイティブ実行可能ファイルを生成します。 |
9 | Always run integration tests when building a native image (test names *IT and annotated with @QuarkusIntegrationTest or @NativeImageTest ). + If you do not wish to run integration tests when building a native image, simply remove this property altogether or set its value to true . |
fast-jar の使用
fast-jar
は、デフォルトの quarkus パッケージタイプです。
ビルドの結果は、 quarkus-app
という名前の target
の下のディレクトリーです。
アプリケーションを実行するには、次のようにします: java -jar target/quarkus-app/quarkus-run.jar
生成された jar を正常に実行するためには、 quarkus-app ディレクトリのすべての内容が必要です。いずれかのファイルが欠落していると、アプリケーションが起動しなかったり、正しく機能しない可能性があります。
|
fast-jar パッケージングでは、どの依存関係のjarにクラスやリソースが含まれているかという情報がインデックス化されているため、レガシーのQuarkus jarよりも起動が少し速く、メモリ消費量もわずかに少ないアーティファクトを作成できます。このため、クラスやリソースをロードする際に、レガシー jar が必要とするクラスパス上のすべての jar を検索する必要がなくなります。
|
Uber-Jar の作成
Quarkus Maven プラグインは、application.properties
(または pom.xml
内の <quarkus.package.type>uber-jar</quarkus.package.type>
) で quarkus.package.type=uber-jar
設定オプションを指定することで、Uber-Jars の生成をサポートしています。
The original jar will still be present in the target
directory, but it will be renamed to contain the .original
suffix.
Uber-jar をビルドする際に、 quarkus.package.ignored-entries
設定オプションを使用して生成された jar から除外したいエントリーを指定することができます。
デフォルトでは、Uber-Jar の作成は、アプリケーションの依存関係に存在する可能性のある 署名ファイルを除外します。
Uber-Jarの最終的な名前は、Mavenのビルド設定 finalName
オプションで設定できます。
Uber-Jar file name suffix
By default the generated uber JAR file name will have the -runner
suffix, unless it was overriden by configuring a custom one with quarkus.package.runner-suffix
configuration option. If the runner suffix is not desired, it can be disabled by setting quarkus.package.add-runner-suffix
configuration option to false
, in which case the uber JAR will replace the original JAR file generated by maven-jar-plugin
for the application module.
マルチモジュールプロジェクトでの作業
デフォルトでは、Quarkusは別のモジュール内のCDI Bean を検出しません。
The best way to enable CDI bean discovery for a module in a multi-module project would be to include the jandex-maven-plugin
, unless it is the main application module already configured with the quarkus-maven-plugin, in which case it will be indexed automatically.
<build>
<plugins>
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
このトピックの詳細については、CDI ガイドの Bean Discovery セクションを参照してください。
特定の設定プロファイルでビルド
Quarkusは、対象となる環境に応じて特定の設定を提供するために、 設定プロファイルをサポートしています。
以下のタイプのコマンドを持つシステムプロパティー quarkus.profile
により、プロファイルは Maven ビルドのコマンドで直接提供できます。
quarkus build -Dquarkus.profile=profile-name-here
./mvnw clean package -Dquarkus.profile=profile-name-here
However, it is also possible to specify the profile directly in the POM file of the project using project properties, the Quarkus Maven plugin configuration properties or system properties set in the Quarkus Maven plugin configuration.
優先順位の高い順 (優先順位が高い方が先):
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<build>
<plugins>
...
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<configuration>
<systemProperties>
<quarkus.profile>prod-aws</quarkus.profile> (1)
</systemProperties>
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>
1 | このプロジェクトのデフォルトの設定プロファイルは prod-aws です。 |
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<build>
<plugins>
...
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<configuration>
<properties>
<quarkus.profile>prod-aws</quarkus.profile> (1)
</properties>
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>
1 | このプロジェクトのデフォルトの設定プロファイルは prod-aws です。 |
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<properties>
<quarkus.profile>prod-aws</quarkus.profile> (1)
...
</properties>
...
</project>
1 | このプロジェクトのデフォルトの設定プロファイルは prod-aws です。 |
どのアプローチを選択しても、プロファイルは quarkus.profile システムプロパティーまたは QUARKUS_PROFILE 環境変数で引き続きオーバーライドすることができます。
|
1つのモジュールから複数のアーティファクトの作成
いくつかの特定のユースケースでは、同じモジュールからアプリケーションのいくつかのアーティファクトをビルドすることが興味深い場合があります。典型的な例は、さまざまな設定プロファイルを使用してアプリケーションをビルドする場合です。
この場合、Quarkus Maven プラグイン設定に必要な数の実行を追加することができます。
以下は、同じアプリケーションの 2 つのビルド (1 つは prod-oracle
プロファイルを使用し、もう 1 つは prod-postgresql
プロファイルを使用) を生成する Quarkus Maven プラグイン設定の例です。
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<build>
<plugins>
...
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>oracle</id>
<goals>
<goal>build</goal>
</goals>
<configuration>
<properties>
<quarkus.profile>prod-oracle</quarkus.profile> (1)
<quarkus.package.output-directory>oracle-quarkus-app</quarkus.package.output-directory> (2)
</properties>
</configuration>
</execution>
<execution>
<id>postgresql</id>
<goals>
<goal>build</goal>
</goals>
<configuration>
<properties>
<quarkus.profile>prod-postgresql</quarkus.profile> (3)
<quarkus.package.output-directory>postgresql-quarkus-app</quarkus.package.output-directory> (4)
</properties>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
...
</project>
1 | プラグインの最初の実行のデフォルトの設定プロファイルは prod-oracle です。 |
2 | プラグインの最初の実行の出力ディレクトリーは、専用ディレクトリーを持つために、quarkus-app ではなく oracle-quarkus-app に設定されます。 |
3 | プラグインの 2 回目の実行のデフォルトの設定プロファイルは prod-postgresql です。 |
4 | プラグインの 2 回目の実行の出力ディレクトリーは、専用ディレクトリーを持つために、quarkus-app ではなく postgresql-quarkus-app に設定されます。 |
上記の設定では、両方のプロファイルビルドが同じ依存関係を使用するため、アプリケーションに Oracle ドライバーと PostgreSQL ドライバーの依存関係を追加すると、両方のドライバーが両方のビルドに表示されることになります。 |
プロファイル固有の依存関係を他のプロファイルから分離するために、JDBC ドライバーをオプションの依存関係としてアプリケーションに追加できますが、それらを必要とする各プロファイルに含まれるように設定されます。以下に例を示します。
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<dependencies>
...
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.driver.version}</version>
<optional>true</optional> (1)
</dependency>
</dependencies>
<build>
<plugins>
...
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
...
<execution>
<id>postgresql</id>
<goals>
<goal>build</goal>
</goals>
<configuration>
<properties>
<quarkus.profile>prod-postgresql</quarkus.profile>
<quarkus.package.output-directory>postgresql-quarkus-app</quarkus.package.output-directory>
<quarkus.package.filter-optional-dependencies>true</quarkus.package.filter-optional-dependencies> (2)
<quarkus.package.included-optional-dependencies>org.postgresql:postgresql::jar</quarkus.package.included-optional-dependencies> (3)
</properties>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
...
</project>
1 | PostgreSQLのJDBCドライバは、オプションの依存関係として定義されています。 |
2 | 後方互換性の理由から、オプションの依存関係をフィルタリングする必要があることを明示的に示す必要があります。 |
3 | PostgreSQLのJDBCドライバに対応するオプションの依存関係のみが、最終的な成果物として期待されます。 |
プロジェクト出力の設定
プロジェクトのビルドの出力を定義するための設定オプションがいくつかあります。これらは他の設定プロパティーと同じように application.properties
で提供されています。
プロパティーは以下の通りです:
ビルド時に固定される設定プロパティ - それ以外の設定プロパティは実行時に上書き可能
タイプ |
デフォルト |
|
---|---|---|
The requested output type. The default built in types are 'jar' (which will use 'fast-jar'), 'legacy-jar' for the pre-1.12 default jar packaging, 'uber-jar', 'native' and 'native-sources'. Environment variable: |
string |
|
If the Implementation information should be included in the runner jar’s MANIFEST.MF. Environment variable: |
boolean |
|
The entry point of the application. This can either be a fully qualified name of a standard Java class with a main method, or Environment variable: |
string |
|
Files that should not be copied to the output artifact Environment variable: |
list of string |
|
List of all the dependencies that have been defined as optional to include into the final package of the application. Each optional dependency needs to be expressed in the following format:
groupId:artifactId:classifier:type
With the classifier and type being optional.
If the type is missing, the artifact is assumed to be of type Environment variable: |
list of string |
|
Flag indicating whether the optional dependencies should be filtered out or not. This parameter is meant to be used in modules where multi-builds have been configured to avoid getting a final package with unused dependencies. Environment variable: |
boolean |
|
The suffix that is applied to the runner jar and native images Environment variable: |
string |
|
Indicates whether the generated binary file (uber-jar or native image) should have the runner suffix appended. Turning off the runner suffix in case of the uber-jar package type, the original build system (Maven, Gradle, etc) built JAR will be replaced with the Quarkus built uber JAR. Environment variable: |
boolean |
|
The output folder in which to place the output, this is resolved relative to the build systems target directory. Environment variable: |
string |
|
The name of the final artifact Environment variable: |
string |
|
Whether to automate the creation of AppCDS. This has no effect when a native binary is needed and will be ignored in that case. Furthermore, this option only works for Java 11+ and is considered experimental for the time being. Finally, care must be taken to use the same exact JVM version when building and running the application. Environment variable: |
boolean |
|
When AppCDS generation is enabled, if this property is set, then the JVM used to generate the AppCDS file will be the JVM present in the container image. The builder image is expected to have the 'java' binary on its PATH. This flag is useful when the JVM to be used at runtime is not the same exact JVM version as the one used to build the jar. Note that this property is consulted only when Environment variable: |
string |
|
Whether creation of the AppCDS archive should run in a container if available.
Normally, if either a suitable container image to create the AppCDS archive inside of can be determined automatically or if one is explicitly set using the Environment variable: |
boolean |
|
This is an advanced option that only takes effect for the mutable-jar format. If this is specified a directory of this name will be created in the jar distribution. Users can place jar files in this directory, and when re-augmentation is performed these will be processed and added to the class-path. Note that before reaugmentation has been performed these jars will be ignored, and if they are updated the app should be reaugmented again. Environment variable: |
string |
|
This option only applies when using fast-jar or mutable-jar. If this option is true then a list of all the coordinates of the artifacts that made up this image will be included in the quarkus-app directory. This list can be used by vulnerability scanners to determine if your application has any vulnerable dependencies. Environment variable: |
boolean |
|
An advanced option that will decompile generated and transformed bytecode into the 'decompiled' directory. This is only taken into account when fast-jar is used. Environment variable: |
boolean |
|
The version of Quiltflower to use Environment variable: |
string |
|
The directory into which to save the fernflower tool if it doesn’t exist Environment variable: |
string |
|
If set to Environment variable: |
boolean |
|
Custom manifest attributes to be added to the main section of the MANIFEST.MF file. An example of the user defined property: quarkus.package.manifest.attributes."Entry-key1"=Value1 quarkus.package.manifest.attributes."Entry-key2"=Value2 Environment variable: |
|
|
Custom manifest sections to be added to the MANIFEST.MF file. An example of the user defined property: quarkus.package.manifest.manifest-sections."Section-Name"."Entry-Key1"=Value1 quarkus.package.manifest.manifest-sections."Section-Name"."Entry-Key2"=Value2 Environment variable: |
|
JVMモードでのカスタムテスト設定プロファイル
By default, Quarkus tests in JVM mode are run using the test
configuration profile. If you are not familiar with Quarkus configuration profiles, everything you need to know is explained in the Configuration Profiles Documentation.
ただし、以下に示すMaven SurefireおよびMaven Failsafe構成で、テストにカスタム設定プロファイルを使用することは可能です。これは、例えば、デフォルトのテストデータベースではない特定のデータベースを使用してテストを実行する必要がある場合に便利です。
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<quarkus.test.profile>foo</quarkus.test.profile> (1)
<buildDirectory>${project.build.directory}</buildDirectory>
[...]
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<quarkus.test.profile>foo</quarkus.test.profile> (1)
<buildDirectory>${project.build.directory}</buildDirectory>
[...]
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
1 | foo 設定プロファイルがテストの実行に使用されます。 |
今のところ、ネイティブモードでカスタムテスト設定プロファイルを使用することはできません。ネイティブテストは常に |
ブートストラップ Maven プロパティー
Quarkus ブートストラップには、アプリケーションのランタイムとビルド時間の依存関係を解決するために使用される Maven リゾルバーの実装が含まれています。Quarkus Maven リゾルバーは、ビルド、テスト、または開発モードを起動したのと同じ Maven コマンドラインから初期化されます。通常、設定を追加する必要はありません。ただし、テストモード、開発モード、または IDE でアプリケーションの依存関係を適切に解決するために、追加の設定オプションが必要になる場合があります。
Maven test plugins (such as surefire
and failsafe
), for example, are not propagating build system properties to the running tests by default. Which means some system properties set by the Maven CLI aren’t available for the Quarkus Maven resolver initialized for the tests, which may result in test dependencies being resolved using different settings than the main Maven build.
以下は、Quarkus bootstrap Maven resolverが初期化時にチェックするシステムプロパティのリストです。
プロパティ名 | デフォルト値 | 説明 |
---|---|---|
|
|
Maven のホームディレクトリは、コマンドラインで |
|
|
カスタム設定ファイルが |
|
|
これがデフォルトのものや `settings.xml`で設定されたものと異なる場合、このプロパティを使用して、カスタムのローカル Maven リポジトリ・ディレクトリを構成することができます。 |
|
none |
This property may be useful to help the Maven resolver identify the top-level Maven project in the workspace. By default, the Maven resolver will be discovering a project’s workspace by navigating the parent-module POM relationship. However, there could be project layouts that are using an aggregator module which isn’t appearing as the parent for its modules. In this case, this property will help the Quarkus Maven resolver to properly discover the workspace. |
|
|
By default, the Quarkus Maven resolver is reading project’s POMs directly when discovering the project’s layout. While in most cases it works well enough and relatively fast, reading raw POMs has its limitation. E.g. if a POM includes modules in a profile, these modules will not be discovered. This system property enables project’s layout discovery based on the effective POM models, that are properly interpolated, instead of the raw ones. The reason this option is not enabled by default is it may appear to be significantly more time-consuming that could increase, e.g. CI testing times. Until there is a better approach found that could be used by default, projects that require it should enable this option. |
上記のこれらのシステムプロパティーは、たとえば、以下のように surefire
および/または failsafe
プラグイン設定に追加できます。
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<maven.home>${maven.home}</maven.home> (1)
<maven.repo.local>${settings.localRepository}</maven.repo.local> (2)
<maven.settings>${session.request.userSettingsFile.path}</maven.settings> (3)
<maven.top-level-basedir>${session.topLevelProject.basedir.absolutePath}</maven.top-level-basedir> (4)
<quarkus.bootstrap.effective-model-builder>true</quarkus.bootstrap.effective-model-builder> (5)
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
1 | Maven CLI によって設定された maven.home システムプロパティーをテストに伝播させます |
2 | テスト用のMavenローカルリポジトリのディレクトリを設定 |
3 | テスト用の Maven 設定ファイルを設定します |
4 | テスト用のトップレベルのプロジェクト・ディレクトリを指定 |
5 | 効果的なPOMベースのプロジェクト・レイアウト・ディスカバリーを有効化 |
トップレベルとマルチモジュールのプロジェクトディレクトリ
Maven では、トップレベルのプロジェクト (プロジェクトプロパティー ${session.topLevelProject.basedir.absolutePath}
として公開) と、マルチモジュールのプロジェクトディレクトリー (プロパティー ${maven.multiModuleProjectDirectory}
として公開) という概念があるようです。これらのディレクトリは常に一致するとは限りません。
maven.multiModuleProjectDirectory は、Maven コード自体が参照することを意図しており、ユーザーコードが頼るべきものではありません。なので、もし便利だと思っても、自分の責任で使ってくださいね。
|
${maven.multiModuleProjectDirectory}
は、mvn
コマンドが起動された現在のディレクトリー (または -f
引数で指定されたディレクトリー) から開始してワークスペースファイルシステムツリーを上る子として .mvn
ディレクトリーを含む最初のディレクトリーに解決されます。ただし、.mvn
ディレクトリーが見つからなかった場合は、${maven.multiModuleProjectDirectory}
は、mvn
コマンドが起動されたディレクトリー (または -f
引数の対象となるディレクトリー) を指すようになります。
${session.topLevelProject.basedir.absolutePath}
は、mvn
コマンドが起動されたディレクトリー、または指定されている場合は -f
引数の対象となるディレクトリーのいずれかを指します。
Quarkus プロジェクト情報
このゴールは、Quarkus Maven プラグイン 2.7.0.Final で導入され、Quarkus バージョン 2.0.0.Final 以降をベースとするプロジェクトで使用できます。 |
Quarkus Maven プラグインには、info
(現在は 'experimental' とマークされています) と呼ばれるゴールが含まれています。これは、インポートされた Quarkus プラットフォーム BOM やプロジェクトの依存関係で見つかった Quarkus エクステンションなど、プロジェクトに関する Quarkus 固有の情報をログに記録するものです。マルチモジュールプロジェクトでは、quarkus:info
は、実行されている現在のモジュールが、アプリケーションのメインモジュールであると想定します。
quarkus:info によって生成されたレポートには、現在 Quarkus Maven プラグイン情報が含まれていませんが、将来のリリースで追加される予定です。
|
単純なプロジェクトの info
出力の例を以下に示します。
[aloubyansky@localhost code-with-quarkus]$ mvn quarkus:info
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< org.acme:code-with-quarkus >---------------------
[INFO] Building code-with-quarkus 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:2.11.1.Final:info (default-cli) @ code-with-quarkus ---
[WARNING] quarkus:info goal is experimental, its options and output may change in future versions
[INFO] Quarkus platform BOMs: (1)
[INFO] io.quarkus.platform:quarkus-bom:pom:2.11.1.Final
[INFO] io.quarkus.platform:quarkus-kogito-bom:pom:2.11.1.Final
[INFO] io.quarkus.platform:quarkus-camel-bom:pom:2.11.1.Final
[INFO]
[INFO] Extensions from io.quarkus.platform:quarkus-bom: (2)
[INFO] io.quarkus:quarkus-resteasy-reactive
[INFO]
[INFO] Extensions from io.quarkus.platform:quarkus-kogito-bom: (3)
[INFO] org.kie.kogito:kogito-quarkus-decisions
[INFO]
[INFO] Extensions from io.quarkus.platform:quarkus-camel-bom: (4)
[INFO] org.apache.camel.quarkus:camel-quarkus-rabbitmq
[INFO]
[INFO] Extensions from registry.quarkus.io: (5)
[INFO] io.quarkiverse.prettytime:quarkus-prettytime:0.2.1
1 | プロジェクトにインポートされた Quarkus プラットフォーム BOM (親 POM によってインポートされた BOM も報告されます) |
2 | quarkus-bom によって管理される直接的な Quarkus エクステンションの依存関係 |
3 | quarkus-kogito-bom によって管理される直接的な Quarkus エクステンションの依存関係 |
4 | quarkus-camel-bom によって管理される直接的な Quarkus エクステンションの依存関係 |
5 | Quarkus BOM によって管理されていないが、Quarkus エクステンションレジストリーで検出された直接的な Quarkus エクステンションの依存関係 |
また、quarkus:info は、Quarkus エクステンションレジストリーにない Quarkus エクステンションがプロジェクトの依存関係に存在する場合は報告し、'不明なオリジン' であることを示します。
|
Highlighting misaligned versions
quarkus:info
は、Quarkus の基本的な依存関係のバージョンの不整合も検出された場合に強調表示します。たとえば、依存関係から kogito-quarkus-decisions
エクステンションを削除し、2.6.3.Final
<version>
要素を quarkus-bom
によって管理されている quarkus-resteasy-reactive
の依存関係に追加することで上記のプロジェクトを変更し、再度 quarkus:info
を実行すると、以下のようになります。
[INFO] --- quarkus-maven-plugin:2.11.1.Final:info (default-cli) @ code-with-quarkus ---
[WARNING] quarkus:info goal is experimental, its options and output may change in future versions
[INFO] Quarkus platform BOMs:
[INFO] io.quarkus.platform:quarkus-bom:pom:2.11.1.Final
[INFO] io.quarkus.platform:quarkus-kogito-bom:pom:2.11.1.Final | unnecessary (1)
[INFO] io.quarkus.platform:quarkus-camel-bom:pom:2.11.1.Final
[INFO]
[INFO] Extensions from io.quarkus.platform:quarkus-bom:
[INFO] io.quarkus:quarkus-resteasy-reactive:2.6.3.Final | misaligned (2)
[INFO]
[INFO] Extensions from io.quarkus.platform:quarkus-camel-bom:
[INFO] org.apache.camel.quarkus:camel-quarkus-rabbitmq
[INFO]
[INFO] Extensions from registry.quarkus.io:
[INFO] io.quarkiverse.prettytime:quarkus-prettytime:0.2.1
[INFO]
[WARNING] Non-recommended Quarkus platform BOM and/or extension versions were found. For more details, please, execute 'mvn quarkus:update -Drectify'
1 | quarkus-kogito-bom のインポートに含まれる Quarkus エクステンションは、どれもプロジェクトの依存関係で見つからないため、このインポートは '不要' と報告されるようになりました。 |
2 | quarkus-resteasy-reactive` のバージョン 2.6.3.Final は、プロジェクトにインポートされた Quarkus プラットフォーム BOM によって管理されているバージョン (2.11.1.Final) と整合性がないと報告されるようになりました。 |
Quarkus プロジェクトの更新
このゴールは、Quarkus Maven プラグイン 2.7.0.Final で導入され、Quarkus バージョン 2.0.0.Final 以降をベースとするプロジェクトで使用できます。 |
QuarkusMaven プラグインによって提供される quarkus:update
ゴール (現在は 'experimental' としてマークされています) を使用して、プロジェクトで利用可能な Quarkus 関連の更新があるかどうかを確認できます。たとえば、プロジェクトに存在する関連する Quarkus プラットフォーム の BOM やプラットフォーム以外の Quarkus エクステンションの新リリースが挙げられます。マルチモジュールプロジェクトでは、update
ゴールはメインの Quarkus アプリケーションモジュールから実行されることを想定しています。
この時点で、quarkus:update のゴールは、推奨される更新を実際に適用するのではなく、単にその内容と手動で適用する方法を報告します。
|
Quarkus Maven プラグインのバージョンは、現在更新レポートに含まれていませんが、将来のリリースで追加される予定です。 |
quarkus:update
が機能する方法では、最初に、プロジェクトのすべての直接的な Quarkus エクステンションの依存関係が収集されます (Quarkus プラットフォームの BOM によって管理されるものと、管理されないけれども Quarkus エクステンションレジストリーにあるもの)。次に、設定された Quarkus エクステンションレジストリー (通常は registry.quarkus.io
) が、最新の推奨/サポートされる Quarkus プラットフォームバージョンおよびそれらと互換性のあるプラットフォーム以外の Quarkus エクステンションについてクエリーされます。続いて、アルゴリズムは、プロジェクトで見つかったすべてのエクステンションの最新の互換性のある組み合わせを選択します (そのような組み合わせが実際に存在する場合)。そうでない場合は、更新は提案されません。
Kogito、Camel、および Quarkus 2.7.1.Final
に基づく Quarkus プラットフォームで利用可能なコア Quarkus エクステンションを含むプロジェクトがあると想定する場合、quarkus:update
の出力は以下のようになります。
[aloubyansky@localhost code-with-quarkus]$ mvn quarkus:update
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< org.acme:code-with-quarkus >---------------------
[INFO] Building code-with-quarkus 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:2.11.1.Final:update (default-cli) @ code-with-quarkus ---
[WARNING] quarkus:update goal is experimental, its options and output might change in future versions
[INFO]
[INFO] Recommended Quarkus platform BOM updates: (1)
[INFO] Update: io.quarkus.platform:quarkus-bom:pom:2.7.1.Final -> 2.11.1.Final
[INFO] Update: io.quarkus.platform:quarkus-kogito-bom:pom:2.7.1.Final -> 2.11.1.Final
[INFO] Update: io.quarkus.platform:quarkus-camel-bom:pom:2.7.1.Final -> 2.11.1.Final
1 | 現在推奨されている Quarkus プラットフォームの BOM 更新のリスト |
通常、単一のプロジェクトプロパティーを使用してすべての Quarkus プラットフォーム BOM を管理しますが、現在の実装はその点を十分に考慮しておらず、各 BOM の更新が個別に報告されます。 |
プロジェクトを変更し、プロジェクトからすべての Kogito エクステンションを削除する場合は、quarkus-resteasy-reactive
エクステンションのバージョンを 2.6.3.Final
に変更し、Quarkus プラットフォームの BOM に含まれていない quarkus-prettytime
を 0.2.0
にダウングレードします。quarkus:update
は以下のように報告します。
[INFO] Recommended Quarkus platform BOM updates: (1)
[INFO] Update: io.quarkus.platform:quarkus-bom:pom:2.7.1.Final -> 2.11.1.Final
[INFO] Update: io.quarkus.platform:quarkus-camel-bom:pom:2.7.1.Final -> 2.11.1.Final
[INFO] Remove: io.quarkus.platform:quarkus-kogito-bom:pom:2.7.1.Final (2)
[INFO]
[INFO] Extensions from io.quarkus.platform:quarkus-bom:
[INFO] Update: io.quarkus:quarkus-resteasy-reactive:2.6.3.Final -> remove version (managed) (3)
[INFO]
[INFO] Extensions from registry.quarkus.io:
[INFO] Update: io.quarkiverse.prettytime:quarkus-prettytime:0.2.0 -> 0.2.1 (4)
1 | プロジェクトに対して現在推奨されている Quarkus プラットフォームの BOM 更新のリスト |
2 | プロジェクトに Kogito エクステンションが含まれていないことを考えると、BOM インポートを削除することをお勧めします |
3 | quarkus-resteasy-reactive の古いバージョンを削除して、quarkus-bom によって管理されているバージョンを優先することをお勧めします。 |
4 | quarkus-prettytime エクステンションの最新の互換性のあるバージョン |
Quarkus プロジェクトの修正
前述のように、quarkus:info
は、Quarkus プラットフォームとエクステンションのバージョンを報告するだけでなく、プロジェクトで使用されるエクステンションのバージョンがインポートされた Quarkus プラットフォームの BOM と互換性があることを確認するために、バージョンの整合性をすばやくチェックします。不整合が検出された場合、以下の警告メッセージがログに記録されます。
[WARNING] Non-recommended Quarkus platform BOM and/or extension versions were found. For more details, please, execute 'mvn quarkus:update -Drectify'
rectify
オプションが有効な場合、quarkus:update
は、最新の推奨される Quarkus バージョンの更新を提案する代わりに、プロジェクトで見つかったエクステンションの依存関係バージョンを現在インポートされている Quarkus プラットフォームの BOM に合わせるための更新手順をログに記録します。