build-native-image-maven
できること
このスキルは、Java 開発者が Maven プロジェクトを、すばやく起動するネイティブプログラムにする手助けをします。より軽く速い Java アプリケーションを求めるチーム向けです。
使う場面
- ✓Maven を使って Java アプリケーションを GraalVM のネイティブイメージとしてビルドしたいとき。
- ✓pom.xml に native-maven-plugin を追加する必要があるとき。
- ✓ネイティブイメージのビルドが失敗し、メタデータの収集や実行時の問題の修正が必要なとき。
スキルのリンク
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/build-native-image-maven/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“pom.xml にネイティブ用のプロファイルを追加して、Java アプリをネイティブイメージとしてビルドできるようにしてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
native-maven-plugin を使ったネイティブプロファイルを pom.xml に追加し、Maven ラッパーでビルドします。プラグインが native-image ツールを見つけられるように、JAVA_HOME を GraalVM JDK に設定します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Maven Native Image Build
Prerequisites
- Set
JAVA_HOMEto a GraalVM JDK installation so the plugin 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. - 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 のバージョンが必要ですか?
Maven 3.6 以降です。
GRAALVM_HOME を使いますか?
通常は使いません。JAVA_HOME に頼り、すでに使っている場合にのみ GRAALVM_HOME に触れます。
ネイティブテストを実行できますか?
はい。ネイティブの JUnit テストのための test-native の実行を設定します。
詳細
作者による元の説明
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
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
build-native-image-gradle
22kエージェントが、Gradle を使って Java アプリを高速な GraalVM のネイティブイメージにビルドし、よくあるビルドや実行時の問題を修正するのを支援します。
building-native-image
22kGraalVM Native Image で Java プログラムを高速なスタンドアロンアプリに変換する方法を、エージェントに教え、よくあるビルドや実行時のエラーを修正させます。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。