Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wgryglas opened this issue Oct 31, 2021 · 1 comment

Comments

@wgryglas
Copy link

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"]
KengoTODA added a commit to KengoTODA/spotbugs-cli that referenced this issue Nov 7, 2021
@KengoTODA
Copy link

I met the same issue in my build, here is its log from my workflow run:

Some problems were found with the configuration of task ':generateNativeImageConfig' (type 'DefaultGenerateNativeImageConfigTask').
  - In plugin 'org.mikeneck.graalvm-native-image' type 'org.mikeneck.graalvm.DefaultGenerateNativeImageConfigTask' property 'javaExecutions.$0.mainClass' doesn't have a configured value.
    
    Reason: This property isn't marked as optional and no value has been configured.
    
    Possible solutions:
      1. Assign a value to 'javaExecutions.$0.mainClass'.
      2. Mark property 'javaExecutions.$0.mainClass' as optional.
    
    Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#value_not_set for more details about this problem.

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

No branches or pull requests

2 participants