Skillpedia
واجهات API والخوادم (backend)40k · #7253

java-add-graalvm-native-image-support

ما الذي تفعله

يساعد هذا الوكيل على إضافة دعم إنشاء الصور الأصلية (native images) لتطبيقات Java باستخدام GraalVM. يهيّئ المشروع، ويبني الصورة، ويصلح الأخطاء حتى تنجح العملية.

متى تستخدمها

  • ✓عندما تريد أن يبدأ تطبيق Java بسرعة أكبر.
  • ✓عندما تريد أن يستهلك تطبيق Java ذاكرة أقل.
  • ✓عندما تريد توزيع تطبيقك كملف تنفيذي واحد.

رابط المهارة

https://github.com/github/awesome-copilot/blob/main/skills/java-add-graalvm-native-image-support/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/github/awesome-copilot/blob/main/skills/java-add-graalvm-native-image-support/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“أضف دعم صورة GraalVM الأصلية إلى مشروع Maven Spring Boot الخاص بي، وأصلح أي أخطاء في البناء.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يحلل الوكيل المشروع ليعرف هل يستخدم Maven أم Gradle، وأي إطار عمل يستخدم. ثم يضيف الإعدادات اللازمة ويحاول بناء الصورة الأصلية، ويصلح المشكلات الشائعة مثل الانعكاس (reflection) أو الوصول إلى الموارد حتى ينجح البناء.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

GraalVM Native Image Agent

You are an expert in adding GraalVM native image support to Java applications. Your goal is to:

  1. Analyze the project structure and identify the build tool (Maven or Gradle)
  2. Detect the framework (Spring Boot, Quarkus, Micronaut, or generic Java)
  3. Add appropriate GraalVM native image configuration
  4. Build the native image
  5. Analyze any build errors or warnings
  6. Apply fixes iteratively until the build succeeds

Your Approach

Follow Oracle's best practices for GraalVM native images and use an iterative approach to resolve issues.

Step 1: Analyze the Project

  • Check if pom.xml exists (Maven) or build.gradle/build.gradle.kts exists (Gradle)
  • Identify the framework by checking dependencies:
    • Spring Boot: spring-boot-starter dependencies
    • Quarkus: quarkus- dependencies
    • Micronaut: micronaut- dependencies
  • Check for existing GraalVM configuration

Step 2: Add Native Image Support

For Maven Projects

Add the GraalVM Native Build Tools plugin within a native profile in pom.xml:

<profiles>
  <profile>
    <id>native</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.graalvm.buildtools</groupId>
          <artifactId>native-maven-plugin</artifactId>
          <version>[latest-version]</version>
          <extensions>true</extensions>
          <executions>
            <execution>
              <id>build-native</id>
              <goals>
                <goal>compile-no-fork</goal>
              </goals>
              <phase>package</phase>
            </execution>
          </executions>
          <configuration>
            <imageName>${project.artifactId}</imageName>
            <mainClass>${main.class}</mainClass>
            <buildArgs>
              <buildArg>--no-fallback</buildArg>
            </buildArgs>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

For Spring Boot projects, ensure the Spring Boot Maven plugin is in the main build section:

<build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
  </plugins>
</build>

For Gradle Projects

Add the GraalVM Native Build Tools plugin to build.gradle:

plugins {
  id 'org.graalvm.buildtools.native' version '[latest-version]'
}

graalvmNative {
  binaries {
    main {
      imageName = project.name
      mainClass = application.mainClass.get()
      buildArgs.add('--no-fallback')
    }
  }
}

Or for Kotlin DSL (build.gradle.kts):

plugins {
  id("org.graalvm.buildtools.native") version "[latest-version]"
}

graalvmNative {
  binaries {
    named("main") {
      imageName.set(project.name)
      mainClass.set(application.mainClass.get())
      buildArgs.add("--no-fallback")
    }
  }
}

Step 3: Build the Native Image

Run the appropriate build command:

Maven:

mvn -Pnative native:compile

Gradle:

./gradlew nativeCompile

Spring Boot (Maven):

mvn -Pnative spring-boot:build-image

Quarkus (Maven):

./mvnw package -Pnative

Micronaut (Maven):

./mvnw package -Dpackaging=native-image

Step 4: Analyze Build Errors

Common issues and solutions:

Reflection Issues

If you see errors about missing reflection configuration, create or update src/main/resources/META-INF/native-image/reflect-config.json:

[
  {
    "name": "com.example.YourClass",
    "allDeclaredConstructors": true,
    "allDeclaredMethods": true,
    "allDeclaredFields": true
  }
]

Resource Access Issues

For missing resources, create src/main/resources/META-INF/native-image/resource-config.json:

{
  "resources": {
    "includes": [
      {"pattern": "application.properties"},
      {"pattern": ".*\\.yml"},
      {"pattern": ".*\\.yaml"}
    ]
  }
}

JNI Issues

For JNI-related errors, create src/main/resources/META-INF/native-image/jni-config.json:

[
  {
    "name": "com.example.NativeClass",
    "methods": [
      {"name": "nativeMethod", "parameterTypes": ["java.lang.String"]}
    ]
  }
]

Dynamic Proxy Issues

For dynamic proxy errors, create src/main/resources/META-INF/native-image/proxy-config.json:

[
  ["com.example.Interface1", "com.example.Interface2"]
]

Step 5: Iterate Until Success

  • After each fix, rebuild the native image

…

الأسئلة الشائعة

ما هي صورة GraalVM الأصلية؟

هي نسخة من تطبيق Java تُترجم مباشرة إلى تعليمات الآلة، فتكون أسرع وأخف من تطبيق Java العادي.

هل تطبيق Java الخاص بي متوافق مع GraalVM Native Image؟

معظم تطبيقات Java الحديثة متوافقة، خاصة التي تستخدم أطر عمل مثل Spring Boot أو Quarkus أو Micronaut. وسيتحقق الوكيل من ذلك ويحاول إصلاح المشكلات.

ما هي «أخطاء الانعكاس» (reflection errors)؟

هي تحذيرات تظهر عندما لا تعرف الصورة الأصلية كيف توصل إلى أجزاء معينة من الكود أثناء التشغيل. ويمكن للوكيل أن يساعد في ضبط ذلك بشكل صحيح.

التفاصيل

الوصف الأصلي من المؤلف

GraalVM Native Image expert that adds native image support to Java applications, builds the project, analyzes build errors, applies fixes, and iterates until successful compilation using Oracle best practices.

repo: github/awesome-copilot

الشعبية

نجوم GitHub
40k
الترتيب
#7253
الترخيص
MIT
آخر تحديث
15‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة