spring-bootgradlenativegraalvm

Basic Spring Boot native application builds with maven but not with gradle


I have a basic Spring Boot application. With maven configuration everything is fine. I can build a native image and also a container image:

./mvnw -Pnative native:compile -DskipTest
./mvnw -Pnative spring-boot:build-image

The same source with gradle gives an error. I'm almost sure that build.gradle is OK:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.2.5'
    id 'io.spring.dependency-management' version '1.1.4'
    id 'org.graalvm.buildtools.native' version '0.9.28'
}

group = 'dev.sezerb.nativeapp'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

But when I run "gradle bootBuildImage": I get the response below:

 gradle bootBuildImage
> Task :collectReachabilityMetadata FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':collectReachabilityMetadata'.
> Failed to query the value of task ':collectReachabilityMetadata' property 'metadataService'.
   > Failed to create service 'nativeConfigurationService'.
      > Could not create an instance of type org.graalvm.buildtools.gradle.internal.GraalVMReachabilityMetadataService.
         > com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
            at [Source: (BufferedReader); line: 1, column: 0]

Any comments on that?


Solution

  • After changing org.graalvm.buildtools.native from '0.9.28' to '0.10.1', build problem is disappeared. Native image seems working fine.