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

build-native-image-maven

ما الذي تفعله

تساعد هذه المهارة مطوري Java على تحويل مشاريع Maven إلى برامج أصلية تبدأ بسرعة. وهي مخصصة للفرق التي تريد تطبيقات Java أخف وأسرع.

متى تستخدمها

  • ✓عندما تريد بناء تطبيق Java كصورة GraalVM أصلية باستخدام Maven.
  • ✓عندما تحتاج إلى إضافة native-maven-plugin إلى ملف pom.xml.
  • ✓عندما يفشل بناء الصورة الأصلية وتحتاج إلى مساعدة في جمع البيانات الوصفية أو إصلاح مشكلات التشغيل.

رابط المهارة

https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/build-native-image-maven/SKILL.md

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

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

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

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

استخدم هذه المهارة لمساعدتي: https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/build-native-image-maven/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

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

“أضف ملف تعريف native إلى pom.xml الخاص بـ Maven حتى أستطيع بناء تطبيق Java كصورة أصلية.”

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

كيف تعمل

تضيف ملف تعريف native مع native-maven-plugin إلى pom.xml، ثم تبني باستخدام Maven wrapper. وتضبط JAVA_HOME على GraalVM JDK حتى تجد الإضافة أداة native-image.

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

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

Maven Native Image Build

Prerequisites

  • Set JAVA_HOME to a GraalVM JDK installation so the plugin 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.
  • Use Maven 3.6+.

Plugin Setup

Add the following to your pom.xml inside a native profile:

<profiles>
  <profile>
    <id>native</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.graalvm.buildtools</groupId>
          <artifactId>native-maven-plugin</artifactId>
          <version>0.11.1</version>
          <extensions>true</extensions>
          <executions>
            <execution>
              <id>build-native</id>
              <goals>
                <goal>compile-no-fork</goal>
              </goals>
              <phase>package</phase>
            </execution>
            <execution>
              <id>test-native</id>
              <goals>
                <goal>test</goal>
              </goals>
              <phase>test</phase>
            </execution>
          </executions>
          <configuration>
            <mainClass>org.example.Main</mainClass>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

Build and Run

./mvnw -Pnative package                    # Build native image → target/<imageName>
./target/myapp                             # Run the native executable
./mvnw -Pnative test                       # Build and run JUnit tests as a native image
./mvnw -Pnative -DskipTests package        # Skip all tests
./mvnw -Pnative -DskipNativeTests package  # Run JVM tests only, skip native

Plugin Not Resolving or Activating

  • "Could not resolve artifact" — Ensure mavenCentral() is in repositories and the version is correct.
  • "Could not find goal 'compile-no-fork'" — Verify <extensions>true</extensions> is set on the plugin.
  • Build runs without native compilation — Check you are activating the profile: ./mvnw -Pnative package.

Build or Runtime Failures

For class initialization errors, linking issues, memory problems, or unexpected runtime behavior, see references/maven-plugin-options.md.

Missing Reachability Metadata

When native-image reports missing reflection, resources, serialization, or JNI entries, see references/reachability-metadata.md.

Native Testing

For nativeTest failures or setting up native JUnit tests, see references/testing.md.

Reference Files

Topic File
Plugin configuration options references/maven-plugin-options.md
Missing reachability metadata references/reachability-metadata.md
Native testing references/testing.md
الأسئلة الشائعة

ما إصدار Maven المطلوب؟

الإصدار 3.6 أو أحدث.

هل تستخدم GRAALVM_HOME؟

غالبًا لا. تعتمد على JAVA_HOME، ولا تذكر GRAALVM_HOME إلا إذا كنت تستخدمه أصلًا.

هل تستطيع تشغيل الاختبارات الأصلية؟

نعم. تعد تنفيذ test-native للاختبارات الأصلية لـ JUnit.

التفاصيل

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

Build GraalVM native images using the native-maven-plugin (org.graalvm.buildtools). Use this skill to build Java applications with Maven, configure pom.xml native image settings, run native tests, collect metadata, or resolve build or runtime issues.

repo: oracle/graal

الشعبية

نجوم GitHub
22k
الترتيب
#10357
الترخيص
—
آخر تحديث
2‏/11‏/2026

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

0

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

التعليقات

  • …

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

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