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

Compatibility issue with several generation task plugins after upgrading to version 8.10

Open Sax388 opened this issue 1 year ago • 10 comments

Plugin config

id 'io.freefair.lombok' version '8.10'
id 'org.openapi.generator' version '7.8.0'

Error message

Reason: Task ':app:generateEffectiveLombokConfig' uses this output of task ':app:openApiGenerate' without declaring an explicit or implicit dependency.

Background

See https://github.com/openapi-processor/openapi-processor-gradle/issues/25#issuecomment-2311799595.

Sax388 avatar Aug 28 '24 12:08 Sax388

Maybe I meet the same issue. In my case I use Spring Cloud Contract, and get error: Reason: Task ':generateContractTestEffectiveLombokConfig' uses this output of task ':generateContractTests' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed

It's all right on 8.7.1 and only throw this error on 8.10

macdao avatar Aug 28 '24 13:08 macdao

Thanks @macdao for chiming in. I've modified the title. So this would be the combination producing the error:

plugins {
  id 'io.freefair.lombok' version '8.10'
  id "org.springframework.cloud.contract" version "4.1.4"
}

Sax388 avatar Aug 28 '24 13:08 Sax388

I was not able to reproduce this locally. Do you have an (example) project which I can use to debug this?

larsgrefer avatar Aug 30 '24 22:08 larsgrefer

@larsgrefer I put an example project here https://github.com/macdao/gradle-plugins-issues-1193 hope this helps

macdao avatar Sep 02 '24 04:09 macdao

I am also able to reproduce this error.

id "io.freefair.lombok" version "8.10"
with 
id 'org.openapi.generator' version '7.8.0'

Seems to cause this issue.

Relevant stackoverflow: https://stackoverflow.com/questions/78979935/lombok-plugin-gradle-error-generateeffectivelombokconfig-uses-task-without-decl

Suggested solution did not work for me however

T00fy avatar Sep 26 '24 11:09 T00fy

The problem commits are these: b78c34ea8a770bdac85148c3614c7d22e74473b2 48d2723f3e136b3fdbf064229ef51c151f7a867b 08494cbb9fb69174ea5ca73e2f075a594375a223 48672d4efb89fc6a20a4f1e380b6cd3ec80adf0a f7e396011947f4522828bc97cfe20468560ab4fc

or the revert as a diff

@@ -81,8 +81,7 @@ public abstract class LombokConfig extends DefaultTask implements LombokTask {
     /**
      * Paths to java files or directories the configuration is to be printed for.
      */
-    @InputFiles
-    @PathSensitive(PathSensitivity.RELATIVE)
+    @Internal
     public abstract ConfigurableFileCollection getPaths();

     @OutputFile
@@ -100,10 +99,18 @@ public abstract class LombokConfig extends DefaultTask implements LombokTask {
         getOutputs().doNotCacheIf("Config Imports were used", t -> ((LombokConfig) t).getConfigFiles() == null);
     }

+    @Input
+    protected List<String> getInputPaths() {
+        return getPaths().getFiles()
+                .stream()
+                .map(File::getPath)
+                .collect(Collectors.toList());
+    }
+
     @InputFiles
     @Optional
     @Nullable
-    @PathSensitive(PathSensitivity.RELATIVE)
+    @PathSensitive(PathSensitivity.ABSOLUTE)
     @SneakyThrows
     protected Set<File> getConfigFiles() {
         if (getPaths().isEmpty()) {

If you apply that, it no longer throws the implicit dependency error

T00fy avatar Sep 26 '24 11:09 T00fy

@T00fy Great job tracking this down. Thanks!

frankjkelly avatar Oct 03 '24 12:10 frankjkelly

@larsgrefer the fix in 8.10.2 still causes the error for me:

> Task :generateTestEffectiveLombokConfig FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':generateTestEffectiveLombokConfig' (type 'LombokConfig').
  - Gradle detected a problem with the following location: '/Users/project/build/generated-sources/src/main/java'.

    Reason: Task ':generateTestEffectiveLombokConfig' uses this output of task ':openApiGenerate' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':openApiGenerate' as an input of ':generateTestEffectiveLombokConfig'.
      2. Declare an explicit dependency on ':openApiGenerate' from ':generateTestEffectiveLombokConfig' using Task#dependsOn.
      3. Declare an explicit dependency on ':openApiGenerate' from ':generateTestEffectiveLombokConfig' using Task#mustRunAfter.

T00fy avatar Oct 07 '24 09:10 T00fy

This works fine without using openApiGenerate now, thanks for your continued efforts @larsgrefer !

Unfortunately it still doesn't work with openApiGenerate. I've modified the example from @macdao : https://github.com/macdao/gradle-plugins-issues-1193/pull/1 accordingly for you to test.

EDIT: The same happens when using id("com.rivancic.asyncapi-gradle-plugin") version "0.2.0" for asyncApiGenerate.

Sax388 avatar Oct 15 '24 11:10 Sax388

Is there a workaround (regarding the sample project above) we can use in the meantime?

Sax388 avatar Oct 23 '24 09:10 Sax388

here a workaround solution :

tasks.configureEach {
    if (name == "generateEffectiveLombokConfig") {
            inputs.dir(tasks.named('generateJooqClasses').get().outputs.files.singleFile)
            dependsOn tasks.named('generateJooqClasses')
    }
}

replace generateJooqClasses with openApiGenerate

KadarH avatar Oct 31 '24 14:10 KadarH

Thanks a ton @KadarH , I've added it to the pull request here: https://github.com/macdao/gradle-plugins-issues-1193/pull/1.

Sax388 avatar Nov 04 '24 10:11 Sax388

For me 8.11 fixed this

Desoroxxx avatar Nov 20 '24 16:11 Desoroxxx

For me 8.11 fixed this

Same for me 8.11 does not have this issue.

frankjkelly avatar Nov 27 '24 13:11 frankjkelly

I'm sorry, I forgot to come back to you. Yes, it does. What I did though, was update the minimal reproducible example here: https://github.com/freefair/gradle-plugins/issues/1193#issuecomment-2454323110. And there I just removed the workaround together with the new version.

Thanks a million @larsgrefer for your continued efforts!

Sax388 avatar Nov 27 '24 20:11 Sax388