-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Conditional Metadata instead of Standard Metadata (#567)
* - Use Conditional Metadata instead of Standard Metadata - Update Maven Wrapper to 3.2.0 - Update Native Build Tools to 0.9.26 - Updated contributor guidelines * Remove all JMX related GraalVM Reachability Metadata * Migrate the GraalVM Reachability Metadata under the test package to the main package
- Loading branch information
1 parent
563522d
commit 9e02908
Showing
18 changed files
with
674 additions
and
665 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ cd ./dynamic-datasource/ | |
./mvnw -am -pl dynamic-datasource-spring-boot3-starter -PnativeTestInSpringBoot -T1C -B clean test | ||
``` | ||
|
||
贡献者在提交 PR 后,位于 Github Actions 的 CI 将进行此验证。如果 nativeTest 执行失败,请跳转到[本文的 2.2一节](./CONTRIBUTING.md)。 | ||
贡献者在提交 PR 后,位于 Github Actions 的 CI 将进行此验证。如果 nativeTest 执行失败,请跳转到[本文的 2.2 一节](./CONTRIBUTING.md)。 | ||
|
||
当贡献者发现缺少与 `dynamic-datasource` 无关的第三方库的 GraalVM Reachability Metadata 时,应当在 | ||
https://github.com/oracle/graalvm-reachability-metadata 打开新的 issue, 并提交包含依赖的第三方库缺失的 GraalVM Reachability | ||
|
@@ -59,20 +59,43 @@ Metadata 的 PR。 | |
## 2.2 Generate or merge GraalVM Reachability Metadata for unit tests | ||
|
||
如果 nativeTest 执行失败, 应为单元测试生成初步的 GraalVM Reachability Metadata,并手动调整以修复 nativeTest。 | ||
如有需要,请使用 `org.junit.jupiter.api.condition.DisabledInNativeImage` 注解屏蔽部分单元测试。 | ||
如有需要,请使用 `org.junit.jupiter.api.condition.DisabledInNativeImage` 注解或 `org.graalvm.nativeimage.imagecode` 的 | ||
System Property 屏蔽部分单元测试在 GraalVM Native Image 下运行。 | ||
|
||
请不要为 SpEL 功能编写可能的 nativeTest,参考 https://github.com/spring-projects/spring-framework/issues/29548 。如有需要, | ||
请使用 `org.graalvm.nativeimage.imagecode` 的 System Property 屏蔽相关测试在 GraalVM Native Image 下运行。 | ||
请不要为 SpEL 功能编写可能的 nativeTest,参考尚未关闭的 https://github.com/spring-projects/spring-framework/issues/29548 。 | ||
|
||
项目定义了 `generateMetadata` 的 Maven Profile 用于在普通 JVM 下携带 GraalVM Tracing Agent 执行单元测试,并在特定目录下生成或合并 | ||
已有的 GraalVM Reachability Metadata 文件。可通过如下 bash 命令简单处理此流程。贡献者仍可能需要手动调整具体的 JSON 条目,并在适当的时候 | ||
调整 Maven Profile 和 GraalVM Tracing Agent 的 Filter 链。 | ||
|
||
以下命令仅为 `dynamic-datasource-spring-boot3-starter` 生成 Conditioanl 形态的 GraalVM Reachability Metadata 的一个举例。 | ||
在 https://github.com/graalvm/native-build-tools/issues/500 关闭之前,你都需要手动调整 `native-image-configure` 的 `input-dir` | ||
为 `./mvnw -PgenerateMetadata -DskipNativeTests -e clean test` 真实的输出目录。 | ||
|
||
对于测试类和测试文件独立使用的 GraalVM Reachability Metadata,贡献者应该放置到相关子模块对应的 | ||
`${project.basedir}/src/test/resources/META-INF/native-image/${project.artifactId}-test-metadata/` 文件夹下。`${}` 内为 | ||
POM 4.0 的常规系统变量,自行替换。 | ||
|
||
```bash | ||
./mvnw -T1C -B -PgenerateMetadata -DskipNativeTests clean test | ||
./mvnw -am -pl dynamic-datasource-spring-boot3-starter -PnativeTestInSpringBoot -T1C -B clean test | ||
git clone [email protected]:baomidou/dynamic-datasource.git | ||
|
||
cd ./dynamic-datasource/ | ||
|
||
./mvnw -PgenerateMetadata -DskipNativeTests -e clean test | ||
|
||
mkdir -p "./dynamic-datasource-spring-boot3-starter/src/test/resources/META-INF/native-image/com.baomidou/dynamic-datasource-spring-boot3-starter/" | ||
|
||
native-image-configure generate-conditional\ | ||
--user-code-filter="./native-image/user-code-filter.json"\ | ||
--class-name-filter="./native-image/extra-filter.json"\ | ||
--input-dir="./dynamic-datasource-spring-boot3-starter/target/native/agent-output/test/session-45270-20230907T013541Z/"\ | ||
--output-dir="./dynamic-datasource-spring-boot3-starter/src/main/resources/META-INF/native-image/com.baomidou/dynamic-datasource-spring-boot3-starter/" | ||
|
||
./mvnw -am -pl dynamic-datasource-spring-boot3-starter -PnativeTestInSpringBoot -T1C -B -e clean test | ||
``` | ||
|
||
请手动删除无任何具体条目的 JSON 文件。 | ||
|
||
# 3. PR | ||
|
||
PR 应提交到位于 Github 的 Git Mirror,即 https://github.com/baomidou/dynamic-datasource 。 | ||
|
15 changes: 15 additions & 0 deletions
15
...ETA-INF/native-image/com.baomidou/dynamic-datasource-spring-boot3-starter/jni-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"condition":{"typeReachable":"com.baomidou.dynamic.datasource.provider.AbstractJdbcDataSourceProvider"}, | ||
"name":"[Lcom.sun.management.internal.DiagnosticCommandArgumentInfo;" | ||
}, | ||
{ | ||
"condition":{"typeReachable":"com.baomidou.dynamic.datasource.provider.AbstractJdbcDataSourceProvider"}, | ||
"name":"[Lcom.sun.management.internal.DiagnosticCommandInfo;" | ||
}, | ||
{ | ||
"condition":{"typeReachable":"com.baomidou.dynamic.datasource.provider.AbstractJdbcDataSourceProvider"}, | ||
"name":"java.util.Arrays", | ||
"methods":[{"name":"asList","parameterTypes":["java.lang.Object[]"] }] | ||
} | ||
] |
Oops, something went wrong.