Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openApiFile property of ResolveTask in Gradle plugin doesn't support lazy configuration and task dependency inference #4366

Open
erdi opened this issue Feb 21, 2023 · 3 comments

Comments

@erdi
Copy link

erdi commented Feb 21, 2023

Some properties of ResolveTask, like for example classpath or buildClasspath support lazy configuration and task dependency inference because their type allows assigning a FileCollection which supports these Gradle features. Unfortunately it's not the case for openApiFile which uses File as the type. RegularFileProperty has been introduced in Gradle 4.3 which if used as the type for openApiFile would allow to lazy configure it and infer task dependencies.

In my case I'm generating the config file using another task so I would like to be able to do

val generateSwaggerConfig = tasks.register<GenerateSwaggerFile>("generateSwaggerConfig") {
    configFile.set(layout.buildDirectory.file("${name}/config.yaml")) // configFile is a RegularFileProperty
}

tasks.named<ResolveTask>("resolve") {
    openApiFile.set(generateSwaggerConfig.map { it.configFile })
}

which would allow Gradle to infer that to run resolve it needs to run generateSwaggerConfig first.

Please let me know if you are accepting PRs as I'd like to contribute a hopefully backwards change with this enhancement.

@frantuma
Copy link
Member

frantuma commented Mar 1, 2023

@erdi thanks for reporting this and for investigation. We certainly welcome PRs and would appreciate a backward compatible fix

@nbrugger-tgm
Copy link

Fix is here: #4761
@frantuma

@nbrugger-tgm
Copy link

@frantuma could I get a review of my pr? Will it be considered for merging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants