Closed tomfi closed 3 years ago
The mainClass
property cannot be optional, because nativeImage
task and generateNativeImageConfig
task are sharing the same mainClass
property. Without setting mainClass
property, the later task(generateNativeImageConfig
) will fail.
This means that we needs refactoring this plugin for realizing this feature. We have to introduce a convention object with the same interface to nativeImage
task.
It seems that the shared library feature is limited to Java11 or later.
In PR #147
mainClass
property in nativeImage
taskbuildType {}
block to configure the type of build(executable/shared library).Example configuration of building shared library
nativeImage {
buildType { BuildTypeSelector build ->
build.sharedLibrary
}
}
Example configuration of building executable
nativeImage {
buildType { BuildTypeSelector build ->
build.executable { main = 'com.example.Main' }
}
}
The feature will be available at v1.4.0
.
@mike-neck thank you very much :)
Is it possible to add the option / flag to build a shared library with this plugin?
When adding the
--shared
flag to GraalVM it should not require amain-class
anymore (https://www.graalvm.org/reference-manual/native-image/ImplementingNativeMethodsInJavaWithSVM/#create-a-shared-library)At the moment the maven plugin support it quite well but i could not find a good gradle plugin that supports it.
As a workaround i did the following configuration:
Where
demo.MainKt
is a stub:This results in building a shared library by graalvm as expected.
It would be great if the
mainClass
andexecutableName
were optional to allow building shared libraries with this plugin without workarounds.Thanks in advance, this plugin is great 👍