Skip to content

Depricated "mainClass" property is necessary for "generateNativeImageConfig" to work #175

@wgryglas

Description

@wgryglas

Describe What happened

When trying to run generateNativeImage task gradle complains about Property mainClass not being initialized.
The mainClass under the "nativeImage" is set via buildType { buidl->build.executable(...) }.

How To Reproduce

The following gradle.build.kts configuration causes problem unless you uncomment "mainClass = mainClassPathName"

[....]
nativeImage {
    // mainClass = mainClassPathName     ---> without this line gradle plugin can not run
    graalVmHome = getGraalVmHome()
    buildType { build ->
        build.executable {
            main = mainClassPathName
        }
    }
    executableName = project.name
    outputDirectory = file("$buildDir/$nativeImageDirName")
    arguments(
        "--no-fallback",
        "--initialize-at-run-time=org.lwjgl",
        "--native-image-info",
        "--verbose",
        "-H:TempDirectory=$buildDir/tmp/$nativeImageDirName"
    )
}
generateNativeImageConfig {
    enabled = true
    graalVmHome = getGraalVmHome()
    byRunningApplicationWithoutArguments()
}

Environment

  • OS: [e.g. Ubuntu 18.04]
  • Plugin Version [v1.4.1]
  • Gradle Version [7.1.1]
  • Java Version - 11 open jdk
  • GraalVM version [GraalVM CE 21.3.0, JAVA_VERSION="11.0.13"
    JAVA_VERSION_DATE="2021-10-19"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions