build-native-image-gradle
Skill này làm gì
Skill này giúp nhà phát triển Java biến dự án Gradle thành chương trình native khởi động nhanh. Skill dành cho các nhóm muốn ứng dụng Java nhẹ hơn và nhanh hơn.
Khi nào nên dùng
- ✓Khi bạn muốn build một ứng dụng Java thành GraalVM native image bằng Gradle.
- ✓Khi quá trình build native image lỗi do khởi tạo lớp, liên kết hoặc bộ nhớ.
- ✓Khi bạn cần thiết lập test native hoặc bổ sung metadata reflection còn thiếu cho dự án Gradle.
Liên kết skill
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/build-native-image-gradle/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thiết lập ứng dụng Java Gradle của tôi để build thành GraalVM native image và chạy các test native.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill thêm plugin GraalVM Native Build Tools vào file build, rồi chạy các tác vụ native compile, run và test. Skill dùng GraalVM JDK được đặt làm JAVA_HOME và chỉ tới các hướng dẫn về lỗi build đã biết.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Gradle Native Image Build
Prerequisites
- Set
JAVA_HOMEto a GraalVM JDK installation so Gradle Native Build Tools can findnative-image. - Do not require
GRAALVM_HOMEin the normal case. Only mention it if the user already relies on it or their environment needs an explicit override. - Apply the
application,java-library, orjavaplugin along withorg.graalvm.buildtools.native.
Plugin Setup
Groovy DSL:
plugins {
id 'application'
id 'org.graalvm.buildtools.native' version '0.11.1'
}
Kotlin DSL:
plugins {
application
id("org.graalvm.buildtools.native") version "0.11.1"
}
Build and Run
./gradlew nativeCompile # Build to build/native/nativeCompile/
./gradlew nativeRun # Build and run the native executable
./gradlew nativeTest # Build and run JUnit tests as a native image
Build or Runtime Failures
If the build fails with class initialization, linking errors, memory issues, or the binary behaves incorrectly at runtime, see references/native-image-build-gradle-options.md.
Native Testing
If nativeTest fails or you need to configure native JUnit tests or custom test suites, see references/testing.md.
Missing Reachability Metadata
If a build or runtime error reports missing reflection, resource, serialization, or JNI registrations, see references/reachability-metadata.md.
Reference Files
| Topic | File |
|---|---|
| DSL options and build arguments | references/native-image-build-gradle-options.md |
| Missing reachability metadata | references/reachability-metadata.md |
| Native testing | references/testing.md |
Câu hỏi thường gặp
Cần cài bộ JDK Java nào?
Một GraalVM JDK, đặt làm JAVA_HOME để công cụ native-image được tìm thấy.
Skill có hoạt động với Maven không?
Gradle do skill này phụ trách, còn Maven có skill riêng.
Skill có giúp với metadata còn thiếu không?
Có. Skill xử lý lỗi thiếu metadata reflection và tài nguyên.
Chi tiết
Mô tả gốc của tác giả
Build GraalVM native images using Gradle Native Build Tools. Use this skill to build Java applications with Gradle, configure native-image build.gradle settings, or resolve build or runtime issues.
repo: oracle/graal
Độ phổ biến
- Sao GitHub
- 22k
- Vị trí xếp hạng
- #10356
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
build-native-image-maven
22kGiúp agent của bạn build ứng dụng Java thành GraalVM native image bằng Maven, cấu hình pom.xml, chạy test native và sửa lỗi build.
building-native-image
22kHướng dẫn agent của bạn biến chương trình Java thành ứng dụng độc lập nhanh bằng GraalVM Native Image, và sửa các lỗi build hoặc runtime thường gặp.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.