Skip to content

Conversation

@jdubois
Copy link

@jdubois jdubois commented Dec 9, 2025

This fixes #447 from @SandraAhlgrimm

Pull Request Checklist

  • I have read and followed the CONTRIBUTING.md guidelines.
  • My contribution adds a new instruction, prompt, or chat mode file in the correct directory.
  • The file follows the required naming convention.
  • The content is clearly structured and follows the example format.
  • I have tested my instructions, prompt, or chat mode with GitHub Copilot.
  • I have run npm start and verified that README.md is up to date.

Description

Add support for GraalVM native image builds for Java projects.


Type of Contribution

  • New instruction file.
  • New prompt file.
  • New chat mode file.
  • New collection file.
  • Update to existing instruction, prompt, chat mode, or collection.
  • Other (please specify):

Additional Notes


By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a comprehensive prompt for adding GraalVM Native Image support to Java applications. The prompt provides an expert-level, iterative workflow for analyzing projects, configuring native image builds, resolving errors, and verifying native executables across multiple frameworks (Spring Boot, Quarkus, Micronaut).

Key changes:

  • New prompt file providing step-by-step GraalVM native image configuration guidance
  • Framework-specific instructions for Maven and Gradle projects
  • Detailed troubleshooting and error resolution strategies for common native image issues
  • Comprehensive examples for reflection, resource, JNI, and proxy configurations


```groovy
plugins {
id 'org.graalvm.buildtools.native' version '0.10.0'
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GraalVM Native Build Tools plugin version 0.10.0 appears again here. Please ensure this is the latest version or consider using a placeholder like [latest-version] to avoid outdated version recommendations.

Copilot uses AI. Check for mistakes.

```kotlin
plugins {
id("org.graalvm.buildtools.native") version "0.10.0"
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GraalVM Native Build Tools plugin version 0.10.0 appears again here. Please ensure this is the latest version or consider using a placeholder like [latest-version] to avoid outdated version recommendations.

Copilot uses AI. Check for mistakes.

**Maven:**
```sh
mvn -Pnative native:compile
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Maven command mvn -Pnative native:compile assumes a Maven profile named "native" exists. However, based on the plugin configuration shown earlier (lines 42-62), no profile is defined. The command should be mvn -Pnative-maven-plugin native:compile or simply mvn native:compile if the plugin execution is configured in the default build lifecycle. Consider clarifying which approach is being used or add the profile configuration if the -Pnative flag is intended.

Suggested change
mvn -Pnative native:compile
mvn native:compile

Copilot uses AI. Check for mistakes.

**Spring Boot (Maven):**
```sh
mvn -Pnative spring-boot:build-image
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Maven command mvn -Pnative spring-boot:build-image assumes a Maven profile named "native" exists, but no such profile is shown in the earlier configuration examples. For Spring Boot 3.0+, the recommended approach is to use the Spring Boot Maven plugin with native image support built-in. Consider providing the profile configuration or using a more standard command like mvn spring-boot:build-image -Pnative with a corresponding native profile definition in the pom.xml.

Suggested change
mvn -Pnative spring-boot:build-image
mvn spring-boot:build-image -Dspring-boot.build-image.native=true

Copilot uses AI. Check for mistakes.
5. **Container Image Build**: Use Quarkus container-image extensions:
```properties
quarkus.native.container-build=true
quarkus.native.builder-image=mandrel
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quarkus.native.builder-image=mandrel configuration specifies a builder image name that's incomplete. The full image name should include a version tag, for example: quarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21 or similar. Without a full reference, this configuration may not work as expected.

Suggested change
quarkus.native.builder-image=mandrel
quarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21

Copilot uses AI. Check for mistakes.
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.10.0</version>
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GraalVM Native Build Tools plugin version 0.10.0 should be verified. As of January 2025, this version may be outdated. Consider checking the latest version at https://graalvm.github.io/native-build-tools/latest/index.html and updating to ensure users get the most recent features and bug fixes.

Suggested change
<version>0.10.0</version>
<version>0.10.2</version>

Copilot uses AI. Check for mistakes.

Or register entire packages:
```java
@RegisterForReflection(classNames = {"com.example.package.*"})
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The classNames attribute for @RegisterForReflection doesn't support wildcard patterns like "com.example.package.*" in standard Quarkus. The wildcard syntax shown here won't work. Instead, users should either list individual classes or use the targets attribute with explicit class references, or register packages differently. Consider updating this example to show a valid approach.

Suggested change
@RegisterForReflection(classNames = {"com.example.package.*"})
// Wildcards are NOT supported; list each class explicitly:
@RegisterForReflection(classNames = {"com.example.package.Foo", "com.example.package.Bar"})
// Or, preferably, use the targets attribute with class references:
@RegisterForReflection(targets = {com.example.package.Foo.class, com.example.package.Bar.class})

Copilot uses AI. Check for mistakes.
Comment on lines +165 to +166
{"pattern": ".*\\.yml"},
{"pattern": ".*\\.yaml"}
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The regex pattern .*\\.yml and .*\\.yaml in the resource includes should be escaped properly in JSON. While the current format might work, the more standard JSON representation would use double backslashes: ".*\\\\.yml" and ".*\\\\.yaml" to ensure the pattern is correctly interpreted. However, if this is intended to be literal documentation that users will copy, single backslash is correct.

Suggested change
{"pattern": ".*\\.yml"},
{"pattern": ".*\\.yaml"}
{"pattern": ".*\\\\.yml"},
{"pattern": ".*\\\\.yaml"}

Copilot uses AI. Check for mistakes.
Comment on lines +216 to +217
- Spring Boot 3.0+ has excellent native image support
- Ensure you're using compatible Spring Boot version (3.0+)
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Spring Boot version compatibility should be explicitly mentioned. The statement "Ensure you're using compatible Spring Boot version (3.0+)" is good, but consider being more specific about which Spring Boot versions are tested and recommended for native image support. For example, Spring Boot 3.2+ has enhanced native image capabilities.

Suggested change
- Spring Boot 3.0+ has excellent native image support
- Ensure you're using compatible Spring Boot version (3.0+)
- Spring Boot 3.2+ is recommended for best native image support (with enhanced capabilities and improved compatibility)
- Minimum required version is Spring Boot 3.0, but 3.2 or later is strongly advised

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +9
---
description: '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.'
tools:
- read_file
- replace_string_in_file
- run_in_terminal
- list_dir
- grep_search
---
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a model field to the front matter to specify the AI model this prompt is optimized for. According to repository conventions and the custom guidelines, it's strongly encouraged to specify the model. For example: model: 'Claude Sonnet 4' or model: 'gpt-4.1'. This helps users understand which model will provide the best results with this prompt.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Contributor

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file needs to have a .prompt.md suffix so that it's treated as a prompt file and then run npm start to generate the README changes.

There's also a number of other comments from Copilot, I'm unsure how many are correct though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an instruction to compile to Java Native with GraalVM

2 participants