badass-jlink-plugin icon indicating copy to clipboard operation
badass-jlink-plugin copied to clipboard

IntelliJ IDEA cannot access options list

Open jverne opened this issue 5 years ago • 2 comments

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.

jverne avatar Aug 21 '20 20:08 jverne

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.

siordache avatar Aug 22 '20 08:08 siordache

Sounds good. At least we have this here so if it comes for someone else there is a workaround.

jverne avatar Aug 24 '20 13:08 jverne