[BUG] `GenerateTask` may not use Gradle build cache when file properties contain absolute path references
Created by: erichaagdev
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Some file and directory properties of the GenerateTask
Gradle task are not marked with @InputFile
, @InputDirectory
, etc. or with @PathSensitivity(PathSensitivity.RELATIVE)
. Therefore, they may not always support build caching if one of the property values is using an absolute path reference.
This can happen when a build cache key has been computed using an absolute path reference for a property. For example:
openApiGenerator {
ignoreFileOverride.set("$projectDir/.openapi-generator-ignore")
// remaining configuration ...
}
This may resolve to /Users/eric/Projects/my-api-project/.openapi-generator-ignore
for me, and /home/bob/my_projects/my-api-project/.openapi-generator-ignore
for someone else.
This causes a cache miss to occur.
See also: Path sensitivity and relocatability
openapi-generator version
-
org.openapi.generator
version6.2.0
OpenAPI declaration file content or url
N/A
Generation Details
N/A
Steps to reproduce
- Remove the current build cache at
~/.gradle/caches/build-cache-1
- Clone any Gradle project which uses the
org.openapi.generator
Gradle plugin - Change
ignoreFileOverride
(or any other file/directory property) to use an absolute file path - Run
./gradlew --build-cache clean openApiGenerate
- Clone the same Gradle project to a different directory
- Change the same property from step 3 to use an absolute file path
- Run
./gradlew --build-cache clean openApiGenerate
from the other clone - Status of
openApiGenerate
will beSUCCESS
, but should beFROM-CACHE
Related issues/PRs
-
https://github.com/OpenAPITools/openapi-generator/issues/12303
- This has a PR, but has had no activity since May.
- The proposed fix by itself would also not address this specific issue.
- https://github.com/OpenAPITools/openapi-generator/issues/10214
Suggest a fix
The following properties in GenerateTask
should be marked with an appropriate input/output file/directory annotation and with @PathSensitivity(PathSensitivity.RELATIVE)
:
templateDir
configFile
ignoreFileOverride