Skip to content

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

Open
lfgcampos wants to merge 1 commit 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 1 commit intoswagger-api:masterfrom
lfgcampos:fix/gradle9-property-conventions

Conversation

@lfgcampos
Copy link
Copy Markdown
Contributor

Pull Request

Thank you for contributing to swagger-core!

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


Description

In Gradle 9, calling Property.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.

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

@Optional

public final Property<String> encoding = getProject().getObjects().property(String.class);
public final Property<String> encoding = getProject().getObjects().property(String.class).convention(StandardCharsets.UTF_8.name());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a behavioral change for older systems where the default was not UTF_8, so event though I would be all for having this UTF_8 here at some point for now safer version would probably be Charset.defaultCharset().name()

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.

2 participants