badass-jlink-plugin
badass-jlink-plugin copied to clipboard
IntelliJ IDEA cannot access options list
I've got an IntelliJ IDEA project with a build.gradle like this, as per the examples provided everywhere:
plugins {
id 'org.beryx.jlink' version '2.21.3'
}
jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'fnord'
}
}
The IDE will annotate the options line with
Access to 'options' exceeds its access rights Cannot assign a value to final field 'options'
IntelliJ IDEA has created the jlink plugin extension, along with the final options property, so we are trying to overwrite the already created (final) options. Unless I'm misunderstanding something, I'm assuming what we really want to do is this:
addOptions('--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages')
This uses the addOptions helper to add the options to the existing options property via ListProperty#addAll. I suppose you could also use options.set(...) if you wanted to overwrite whatever is in there already.
This seems to be a known bug in IntelliJ IDEA. The syntax
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
is perfectly legal in Gradle, but you can safely use addOptions(...) to get rid of the IntelliJ IDEA warning.
Sounds good. At least we have this here so if it comes for someone else there is a workaround.