FEATURE: Set config file via system property "lombok.configUri" #2643
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think the added changelog entry says it all:
config file
via the system propertylombok.configUri
(e.g. when using Eclipse, passing-Dlombok.configUri=/path/to/lombok.config
ineclipse.ini
or, in general, setting it via theJAVA_TOOL_OPTIONS
environment variable sojavac
picks it up). This might be useful if the used build tool uses some exotic path system. E.g. starting with version 1.4, sbt (https://www.scala-sbt.org/) usesvf:
instead offile:
, which lombok couldn't handle.So as you can see sbt 1.4 introduces a virtual file system, so the "files" lombok "receives" from sbt are all prefixed with
vf:
(and also have a virtual path, which is different than the actual path on the file system), which lombok just ignores. However Lombok itself works fine, only the config is broken, meaning alllombok.config
files are ignored (sbt/sbt#5968). The relevant code in Lombok can be found here (see the lengthy comment in this code snippet):https://github.com/rzwitserloot/lombok/blob/737dc6e4333c09a0848d2f5b0d621a27a8039a70/src/core/lombok/core/configuration/FileSystemSourceCache.java#L67-L87
This fairly easy fix gives us a workaround, so we can just set the
lombok.configUri
env variable inbuild.sbt
and the specifiedlombok.config
gets picked up. I know with this environment variable we can only define just one config file instead of putting many different config files in different packages/folders, but IMHO having at least a "global" config file is good enough to set at least global config keys. Also, because I re-use theBubblingConfigurationResolver
(mainly because it already handles imports inside a lombok config), bubbling up the directory tree still works.