Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)22k · #10356

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.md

Sao 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

Hãy dùng skill này để giúp tôi: https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/build-native-image-gradle/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

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_HOME to a GraalVM JDK installation so Gradle Native Build Tools can find native-image.
  • Do not require GRAALVM_HOME in 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, or java plugin along with org.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

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự