Pular para o conteúdo
Skillpedia
APIs e servidores (backend)22 mil · #10357

build-native-image-maven

O que ela faz

Esta skill ajuda desenvolvedores Java a transformar seus projetos Maven em programas nativos que iniciam rapidamente. É para equipes que querem aplicações Java mais leves e rápidas.

Quando usar

  • ✓Quando você quiser compilar uma aplicação Java como imagem nativa do GraalVM com o Maven.
  • ✓Quando precisar adicionar o native-maven-plugin a um arquivo pom.xml.
  • ✓Quando um build de imagem nativa falhar e você precisar de ajuda para coletar metadados ou corrigir problemas de execução.

Link da skill

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

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/build-native-image-maven/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Adicione um perfil native ao meu pom.xml do Maven para que eu possa compilar meu app Java como imagem nativa.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

Ela adiciona um perfil native com o native-maven-plugin ao pom.xml e depois compila com o Maven wrapper. Define JAVA_HOME como um JDK do GraalVM para que o plugin encontre a ferramenta native-image.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do 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
Perguntas frequentes

Qual versão do Maven é necessária?

Maven 3.6 ou superior.

Ela usa GRAALVM_HOME?

Normalmente não. Ela depende de JAVA_HOME e menciona GRAALVM_HOME apenas se você já o usa.

Ela consegue executar testes nativos?

Sim. Ela configura uma execução test-native para testes JUnit nativos.

Detalhes

Descrição original do autor

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

Popularidade

Estrelas no GitHub
22 mil
Posição no ranking
#10357
Licença
—
Atualizada em
02/11/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas