xuxiaowei-com-cn opened a new pull request, #8165:
URL: https://github.com/apache/incubator-seata/pull/8165

   <!--
       Licensed to the Apache Software Foundation (ASF) under one or more
       contributor license agreements.  See the NOTICE file distributed with
       this work for additional information regarding copyright ownership.
       The ASF licenses this file to You under the Apache License, Version 2.0
       (the "License"); you may not use this file except in compliance with
       the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
       
       Unless required by applicable law or agreed to in writing, software
       distributed under the License is distributed on an "AS IS" BASIS,
       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       See the License for the specific language governing permissions and
       limitations under the License.
   -->
   <!-- Please make sure you have read and understood the contributing 
guidelines -->
   
   - [ ] I have read the 
[CONTRIBUTING.md](https://github.com/apache/incubator-seata/blob/2.x/CONTRIBUTING.md)
 guidelines.
   - [ ] I have registered the PR 
[changes](https://github.com/apache/incubator-seata/tree/2.x/changes).
   
   ### Ⅰ. Describe what this PR did
   
   This PR adds **GraalVM native image compilation support for the Seata 
namingserver**, enabling the namingserver to be compiled into a standalone 
native binary with sub-second startup and reduced memory footprint.
   
   #### Key changes:
   
   - **Build infrastructure**:
     - Added `native-maven-plugin` (`org.graalvm.buildtools`, v1.1.3) to parent 
POM plugin management.
     - Added `native` profile to `namingserver/pom.xml` with 
`spring-boot:process-aot` and `native:compile` goals.
     - Added `release-seata-jar` profile for producing the executable fat JAR 
via `spring-boot:repackage`.
     - Added OS/arch platform profiles (`native-linux-amd64`, 
`native-linux-aarch64`, `native-darwin-x86_64`, `native-darwin-aarch64`, 
`native-windows-amd64`) for native binary naming.
   
   - **Native image metadata** (auto-generated via 
`-agentlib:native-image-agent`):
     - Added `reflect-config.json` — reflection metadata for Seata classes, 
Spring Boot auto-configuration, Jackson serialization, and Actuator endpoints.
     - Added `resource-config.json` — resource bundle patterns and 
configuration file includes.
     - Added `script/native/merge_native_image_config.py` — utility script to 
merge agent-generated `reachability-metadata.json` into the native-image config 
files. Supports extensible config type mapping.
   
   - **Configuration**:
     - `logback-spring.xml`: Removed `<if>` conditional logic (not supported in 
GraalVM native images at build time). Replaced with fixed `resource` includes 
for `console-appender.xml` and `file-appender.xml`.
     - `pom.xml`: Added Spotless JSON formatting for 
`META-INF/native-image/*.json` files.
   
   - **Makefile**:
     - Added `package-namingserver-native-metadata` — build and package the JAR 
for agent tracing.
     - Added `run-namingserver-native-metadata` — run the JAR with the 
native-image agent to capture reachability metadata.
     - Added `run-merge-native-namingserver` — merge generated metadata into 
config files.
     - Added `package-namingserver-native` — compile the native binary using 
GraalVM.
     - Added `run-namingserver-native-mode-file` — run the compiled native 
binary.
     - Added `package-run-namingserver-native-mode-file` — build and run in one 
step.
     - General Makefile improvements: added phony target declarations, 
comments, and `-e` flag to Maven commands for better error diagnostics.
   
   ### Ⅱ. Does this pull request fix one issue?
   <!-- If that, add "fixes #xxx" below in the next line, for example, fixes 
#97. -->
   
   https://github.com/apache/incubator-seata/issues/8164
   
   ### Ⅲ. Why don't you add test cases (unit test/integration test)? 
   
   
   ### Ⅳ. Describe how to verify it
   
   1. **Prerequisites**: Install GraalVM JDK 21+ with `native-image`.
   
   2. **Generate metadata** (optional — baseline metadata is already committed):
      ```bash
      make package-namingserver-native-metadata
      make run-namingserver-native-metadata
      make run-merge-native-namingserver
      ```
   
   3. **Build the native binary**:
      ```bash
      make package-namingserver-native
      ```
   
   4. **Run the native binary**:
      ```bash
      make run-namingserver-native-mode-file
      ```
      Verify the namingserver starts successfully (expect sub-second startup) 
and responds to HTTP requests.
   
   ### Ⅴ. Special notes for reviews
   
   - The `reflect-config.json` and `resource-config.json` are auto-generated by 
the GraalVM native-image agent. They should be reviewed for completeness but 
expect future iterations as more runtime paths are exercised.
   - The `logback-spring.xml` change removes conditional includes — reviewers 
should confirm this is acceptable for the non-native (JVM) code path as well.
   - The merge script (`merge_native_image_config.py`) is designed to be 
extensible: additional config types can be added by extending the `KEY_TO_FILE` 
dictionary.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to