gradle-plugins icon indicating copy to clipboard operation
gradle-plugins copied to clipboard

generateEffectiveLombokConfig is not cached

Open flocsy opened this issue 2 years ago • 12 comments

When I run gradle build and then without any changes in the code I run gradle build again then all the generateEffectiveLombokConfig tasks are run again even though the code hasn't change. IMHO generateEffectiveLombokConfig should be cached and it should only run again if there was a change in the code. (I'm using 6.4.3)

flocsy avatar Jun 14 '22 09:06 flocsy

Please have a look at https://github.com/freefair/gradle-plugins/pull/525#issuecomment-1136247942

larsgrefer avatar Jun 14 '22 11:06 larsgrefer

@larsgrefer https://github.com/freefair/gradle-plugins/commit/6314b6da5697b03f71adc82f9652f66fbb93dd55 This commit doesn't completely solve the problem for me. After this commit if I make zero changes to my source at all then I get

Task :api-v1:generateEffectiveLombokConfig UP-TO-DATE

but if I make any changes at all to any files - not to config then I get

Task :api-v1:generateEffectiveLombokConfig

and my entire source is recompiled.

This is better than the previous situation (always recompiling everything) but not ideal because if the config hasn't changed then the generateEffectiveLombokConfig should be UP-TO-DATE already and not invalidate the java compile.

mjaggard avatar Sep 16 '22 10:09 mjaggard

Task ':api-v1:generateEffectiveLombokConfig' is not up-to-date because: Input property 'paths' file /path/to/MyClassName.java has changed.

mjaggard avatar Sep 16 '22 11:09 mjaggard

Thats a good point. For the up-to-date check here, I don't care about the contents of your java classes, just where they are.

I'll have a look at this.

larsgrefer avatar Sep 16 '22 15:09 larsgrefer

I'm not sure I fully understand, but doesn't the effective Lombok config only depend on files called lombok.config and those imported by it? I'd assumed that no java classes needed to be used at all?

mjaggard avatar Sep 16 '22 16:09 mjaggard

I'm not sure I fully understand, but doesn't the effective Lombok config only depend on files called lombok.config and those imported by it? I'd assumed that no java classes needed to be used at all?

Thats correct. Given your example path of /path/to/MyClassName.java Lombok would look for these files at first:

  • /path/to/lombok.config
  • /path/lombok.config
  • /lombok.config

It traverses the file system upwards, starting at the java source file. That's why the location of the java sources is important. The content of the source files is not needed.

larsgrefer avatar Sep 16 '22 23:09 larsgrefer

Oh, of course sorry. I forgot that Lombok configuration can be per directory. Thank you.

mjaggard avatar Sep 17 '22 08:09 mjaggard

+1 , using gradle-7.5.1

jenni avatar Nov 15 '22 18:11 jenni

+1 , using gradle-7.5.1

This has been fixed but not released. Locally I'm currently running the main branch as my plugin by installing the plugin into maven local and then referencing that in my project build instead of a release.

It's annoying having to keep merging my local changes in git though and I can't commit it because the build machine doesn't have this plugin snapshot.

mjaggard avatar Nov 15 '22 23:11 mjaggard

Is it possible to include this change in the next version of the plugin?

kancsuki avatar Aug 08 '23 12:08 kancsuki

@kancsuki This should already be released for some time now

larsgrefer avatar Aug 13 '23 22:08 larsgrefer

Hello, am I correct in stating that based on https://github.com/freefair/gradle-plugins/pull/525#issuecomment-1136247942, the LombokConfig task cannot be cacheable?

Running with plugin version 8.4 and Gradle 8.5, I see that the generateTestEffectiveLombokConfig is run multiple times on each build run. Gradle's build scan reports the following:

The task was not up-to-date because of the following reasons: 
Output property 'outputFile' file webapp/cas-server-webapp-tomcat/build/lombok/effective-config/lombok-test.config has been removed.

In this scenario, there exists only one lombok.config file found at the root of the project: https://github.com/apereo/cas/blob/master/lombok.config

While the task typically executes very quickly, in some cases it can take up to 31 seconds or so. Could this task be made cacheable as pointed out here?

mmoayyed avatar Jan 04 '24 11:01 mmoayyed