- quarkus的maven插件非常重要,管理和构建工程时都离不开,本篇就来一起了解和掌握它
欢迎访问我的GitHub
这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
本篇概览
- 本文是《quarkus实战》系列的第五篇,一起去熟悉quarkus的maven插件(就是下图红框中的那个plugin),用好它可以使我们更加得心应手的在项目中配置和控制quarkus
- 插件quarkus-maven-plugin提供了丰富的功能,它们都有对应的命令,执行mvn quarkus:xxx即可执行,其中xxx就是具体的命令,例如mvn quarkus:help,接下来一起用实际操作来熟悉这些命令
帮助(help)
- mvn quarkus:help是首先要掌握的命令,它告诉了大家quarkus的maven插件到底有哪些能力,作为工具书,今后随时可能用到,如下所示,篇幅所限,仅列出部分内容:
% mvn quarkus:help
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.bolingcavalry:hello-quarkus >-------------------
[INFO] Building hello-quarkus 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:2.7.3.Final:help (default-cli) @ hello-quarkus ---
[INFO] Quarkus Platform - Quarkus Maven Plugin 2.7.3.Final
Quarkus Universe platform aggregates extensions from Quarkus Core and those
developed by the community into a single compatible and versioned set that
application developers can reference from their applications to align the
dependency versions
This plugin has 25 goals:
quarkus:add-extension
Allow adding an extension to an existing pom.xml file. Because you can add one
or several extension in one go, there are 2 mojos: add-extensions and
add-extension. Both supports the extension and extensions parameters.
quarkus:add-extensions
Allow adding extensions to an existing pom.xml file. Because you can add one
or several extension in one go, there are 2 mojos: add-extensions and
add-extension. Both supports the extension and extensions parameters.
quarkus:analyze-call-tree
Analyze call tree of a method or a class based on an existing report produced
by Substrate when using -H:+PrintAnalysisCallTree, and does a more meaningful
analysis of what is causing a type to be retained.
quarkus:build
Builds the Quarkus application.
...
创建工程(create)
- 首先要掌握的mvn命令是创建工程,回顾前文中创建工程的命令:
mvn "io.quarkus:quarkus-maven-plugin:create" \
-DprojectGroupId="com.bolingcavalry" \
-DprojectArtifactId="hello-quarkus" \
-DprojectVersion="1.0-SNAPSHOT" \
-DclassName="HobbyResource" \
-Dpath="actions"
- 创建工程时有很多参数可以设置,它们的默认值的作用如下表
参数 | 默认值 | 说明 |
---|---|---|
projectGroupId | org.acme.sample | group id,GAV坐标中的G |
projectArtifactId | mandatory | artifact id, GAV坐标中的A |
projectVersion | 1.0.0-SNAPSHOT | version, GAV坐标中的V |
platformGroupId | io.quarkus.platform | 在依赖quarkus的BOM,以及quarkus插件时,都要指定GAV,这是G |
platformArtifactId | quarkus-bom | 在依赖quarkus的BOM,以及quarkus插件时,都要指定GAV,这是A |
platformVersion | 2.7.1.Final | 在依赖quarkus的BOM,以及quarkus插件时,都要指定GAV,这是V,默认值会自动更新到最新稳定版 |
className | 无默认值 | 指定后,会自动创建一个类 |
path | 无默认值 | 如果指定了className,此时再指定path的话,path会作为类的web接口的path |
extensions | 空 | 所需的quarkus插件列表 |
quarkusRegistryClient | true | 是否联网获取最新的quarkus插件列表,如果设置为false,列表只能根据BOM获取,得不到最新的在线数据 |
查看工程信息(info)
- 查看工程信息的命令是mvn quarkus:info,使用频率很高,如下,可以观察当前的BOM和扩展插件情况:
(base) willdeMBP:hello-quarkus will$ mvn quarkus:info
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.bolingcavalry:hello-quarkus >-------------------
[INFO] Building hello-quarkus 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]