Skip to content

fix(gradle-plugin): add .convention() defaults to Property<T> fields in ResolveTask#5065

Open
lfgcampos wants to merge 3 commits intoswagger-api:masterfrom
lfgcampos:fix/gradle9-property-conventions
Open

fix(gradle-plugin): add .convention() defaults to Property<T> fields in ResolveTask#5065
lfgcampos wants to merge 3 commits intoswagger-api:masterfrom
lfgcampos:fix/gradle9-property-conventions

Conversation

@lfgcampos
Copy link
Copy Markdown
Contributor

@lfgcampos lfgcampos commented Feb 27, 2026

Pull Request

Thank you for contributing to swagger-core!

Please fill out the following information to help us review your PR efficiently.


Closes #5136

Description

In Gradle 9, calling Property<T>.get() on a property that has neither a set value nor a convention throws at runtime:

Cannot query the value of task property '...' because it has no value available.

ResolveTask.resolve() calls .get() unconditionally on prettyPrint, readAllResources, sortOutput, alwaysResolveAppPath, skipResolveAppPath, and encoding. None had a .convention(...) default, so they throw when not explicitly set by the caller.

Fix: add .convention(false) to the five boolean fields and .convention(StandardCharsets.UTF_8.name()) to encoding. Callers that set these explicitly are unaffected.

Property Type Convention Notes
outputFileName Property<String> "openapi" Was unguarded .get()
outputFormat Property<Format> Format.JSON Was unguarded .get()
prettyPrint Property<Boolean> false Matches SwaggerPlugin
readAllResources Property<Boolean> false Matches SwaggerPlugin
encoding Property<String> Charset.defaultCharset().name() Matches SwaggerPlugin
sortOutput Property<Boolean> false Matches SwaggerPlugin
alwaysResolveAppPath Property<Boolean> false Matches SwaggerPlugin
skipResolveAppPath Property<Boolean> false Matches SwaggerPlugin
skip Property<Boolean> false Already safe via .getOrElse(), added for consistency
openAPI31 Property<Boolean> false Matches SwaggerPlugin
convertToOpenAPI31 Property<Boolean> false Fixes latent bug: .get() at line 578 had no isPresent() guard

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues (if any)

Screenshots / Additional Context

@lfgcampos lfgcampos force-pushed the fix/gradle9-property-conventions branch from 341d8a5 to 84d78b1 Compare February 27, 2026 14:28
@ewaostrowska ewaostrowska force-pushed the fix/gradle9-property-conventions branch from 84d78b1 to 3ee8ec3 Compare April 3, 2026 09:04
@ewaostrowska
Copy link
Copy Markdown
Contributor

Hi @lfgcampos! Thanks for pointing this issue out and putting your effort to resolve it.
I have few remarks regarding this issue that I would like fixed before merging this PR:

  1. There's no issue linked for this PR. Please create one and link it in this PR if such issue does not exist yet. This is our main way of documenting and tracking the changes
  2. There seems to be few other cases that potentially could be included in this PR. Please include them or at least address them
  3. No tests for either Gradle 9 or other Gradle versions

@lfgcampos
Copy link
Copy Markdown
Contributor Author

Hi @lfgcampos! Thanks for pointing this issue out and putting your effort to resolve it. I have few remarks regarding this issue that I would like fixed before merging this PR:

  1. There's no issue linked for this PR. Please create one and link it in this PR if such issue does not exist yet. This is our main way of documenting and tracking the changes
  2. There seems to be few other cases that potentially could be included in this PR. Please include them or at least address them
  3. No tests for either Gradle 9 or other Gradle versions

hi @ewaostrowska, thanks for the comments and review!

  1. done, issue created and linked
  2. I've covered another 5 ones that I figured would benefit from. There might be more but I can't possibly define a default sensible value without changing behavious
  3. Added something, hope it is enough!

Also updated the description with a lot more info 🤞

@lfgcampos lfgcampos requested a review from ewaostrowska April 14, 2026 14:05
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

Successfully merging this pull request may close these issues.

[Bug]: Gradle 9 fails to use the lib because of the missing convention

2 participants