[BUG] ValidateTask does not work under Gradle 7.0
Created by: ilya40umov
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
ValidateTask stops working if gradle version is upgraded to 7.0.
The following task definition works under 6.8.3, but fails under 7.0:
val validateOpenApi by registering(ValidateTask::class) {
group = "verification"
description = "Validate openapi.yaml"
recommend.set(true)
input = "$rootDir/openapi.yaml"
}
val check by registering {
dependsOn(validateOpenApi)
}
Here is the output:
* What went wrong:
Some problems were found with the configuration of task ':validateOpenApi' (type 'ValidateTask').
- Type 'ValidateTask' property 'inputSpec' of mutable type 'org.gradle.api.provider.Property' is writable.
Reason: Properties of type 'org.gradle.api.provider.Property' are already mutable.
Possible solution: Remove the 'setInputSpec' method.
Please refer to https://docs.gradle.org/7.0/userguide/validation_problems.html#mutable_type_with_setter for more details about this problem.
- Type 'ValidateTask' property 'recommend' of mutable type 'org.gradle.api.provider.Property' is writable.
Reason: Properties of type 'org.gradle.api.provider.Property' are already mutable.
Possible solution: Remove the 'setRecommend' method.
Please refer to https://docs.gradle.org/7.0/userguide/validation_problems.html#mutable_type_with_setter for more details about this problem.
openapi-generator version
id("org.openapi.generator") version "5.1.0" apply false
Suggest a fix
Apparently the following properties of ValidateTask should not be declared as var
as they are already mutable properties anyway:
@get:InputFile
@PathSensitive(PathSensitivity.RELATIVE)
var inputSpec = project.objects.property<String>()
@Optional
@Input
var recommend = project.objects.property<Boolean?>()