Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #13663
Closed
Open
Issue created Oct 10, 2022 by Administrator@rootContributor3 of 6 checklist items completed3/6 checklist items

[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 version 6.2.0
OpenAPI declaration file content or url

N/A

Generation Details

N/A

Steps to reproduce
  1. Remove the current build cache at ~/.gradle/caches/build-cache-1
  2. Clone any Gradle project which uses the org.openapi.generator Gradle plugin
  3. Change ignoreFileOverride (or any other file/directory property) to use an absolute file path
  4. Run ./gradlew --build-cache clean openApiGenerate
  5. Clone the same Gradle project to a different directory
  6. Change the same property from step 3 to use an absolute file path
  7. Run ./gradlew --build-cache clean openApiGenerate from the other clone
  8. Status of openApiGenerate will be SUCCESS, but should be FROM-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
Assignee
Assign to
Time tracking