Compatibility issue with several generation task plugins after upgrading to version 8.10
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.
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
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"
}
I was not able to reproduce this locally. Do you have an (example) project which I can use to debug this?
@larsgrefer I put an example project here https://github.com/macdao/gradle-plugins-issues-1193 hope this helps
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
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 Great job tracking this down. Thanks!
@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.
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.
Is there a workaround (regarding the sample project above) we can use in the meantime?
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
Thanks a ton @KadarH , I've added it to the pull request here: https://github.com/macdao/gradle-plugins-issues-1193/pull/1.
For me 8.11 fixed this
For me 8.11 fixed this
Same for me 8.11 does not have this issue.
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!