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

Fix Gradle Plugin ValidateTask not working under Gradle 7.0 #9453

Merged
merged 3 commits into from
Jun 3, 2021

Conversation

rm3l
Copy link
Contributor

@rm3l rm3l commented May 11, 2021

This fixes #9328, which prevents from using the OpenAPI Generator Gradle Plugin with the latest Gradle 7.0.

As of Gradle 7.0, an error is returned at configuration time if a plugin task declares a property of "mutable" type with a setter.
See https://docs.gradle.org/7.0/userguide/validation_problems.html#mutable_type_with_setter for further details.

This PR fixes this issue by declaring such properties as Kotlin val members instead, so they do not have setters.
To validate that the fix works, this PR also adds the capability to run the same set of tests in ValidateTaskDslTest using different instances of GradleRunner, configured with different versions of Gradle.

@agilob and @jimschubert I'm mentioning the two of you since you reviewed a similar PR (#9059 ) about GenerateTask.

cc @ilya40umov @wing328

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@rm3l
Copy link
Contributor Author

rm3l commented May 11, 2021

No idea why one of the CI jobs is not passing. And I am not sure this even relates to the changes in this PR.

go: downloading github.com/gorilla/mux v1.7.3
?   	github.com/GIT_USER_ID/GIT_REPO_ID	[no test files]
?   	_/home/circleci/OpenAPITools/openapi-generator/samples/server/petstore/go-gin-api-server	[no test files]
go go: unknown command
Run 'go help' for usage.
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (go-get) on project GoEchoServer: Command execution failed. Process exited with an error: 2 (Exit value: 2) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :GoEchoServer
2021-05-11 20:41:34.459:INFO::main: Logging initialized @132ms
2021-05-11 20:41:34.472:INFO:oejr.Runner:main: Runner
2021-05-11 20:41:34.600:INFO:oejs.Server:main: jetty-9.2.9.v20150224
May 11, 2021 8:41:38 PM com.sun.jersey.api.core.PackagesResourceConfig init

@agilob
Copy link
Contributor

agilob commented May 13, 2021

Doesnt look like its a realted test failure, just wait it out and update your pr in a few days. it happens from time to time.

@rm3l rm3l force-pushed the fix/9328_validatetask_gradle_7 branch 3 times, most recently from ad062e8 to e9bc663 Compare May 20, 2021 22:27
@wing328
Copy link
Member

wing328 commented May 21, 2021

@rm3l thanks for the PR. Is it correct to say that this change is also backward-compatible with Gradle 5.x and 6.x?

@rm3l
Copy link
Contributor Author

rm3l commented May 21, 2021

Is it correct to say that this change is also backward-compatible with Gradle 5.x and 6.x?

Yes, the changes here should be backward-compatible with the older versions of Gradle. In our project at work, I personally tested the changes here against both Gradle 6.9 and Gradle 7.0

To prevent potential regressions in the future, I actually updated the ValidateTaskDslTest test class. The DataProvider added currently runs the same test suite against different versions of Gradle:

  • the version of Gradle used to build the plugin itself (5.6.4 at this time)
  • and Gradle 7.0, which was the reason of the issue

But I will also include Gradle 6.x, so it can be tested as well.

@rm3l rm3l force-pushed the fix/9328_validatetask_gradle_7 branch 6 times, most recently from 1097d48 to eca97f2 Compare May 28, 2021 07:01
@rm3l rm3l force-pushed the fix/9328_validatetask_gradle_7 branch from eca97f2 to 86c1a7a Compare May 30, 2021 21:50
@wing328
Copy link
Member

wing328 commented May 31, 2021

cc @OpenAPITools/generator-core-team

@rm3l rm3l force-pushed the fix/9328_validatetask_gradle_7 branch from 86c1a7a to c035c6a Compare May 31, 2021 20:44
@wing328
Copy link
Member

wing328 commented Jun 1, 2021

If no further feedback, I'll merge this PR tomorrow (Wed).

rm3l added 3 commits June 1, 2021 21:48
This is applicable to the following properties:
- inputSpec
- recommend

Otherwise, Gradle 7.0 now returns an error when attempting
to configure this task.

See https://docs.gradle.org/7.0/userguide/validation_problems.html#mutable_type_with_setter
…slTest

Test against the latests Gradle 5.x and 6.x versions
@rm3l rm3l force-pushed the fix/9328_validatetask_gradle_7 branch from c035c6a to 54543c7 Compare June 1, 2021 19:49
@wing328 wing328 merged commit a8c4cbd into OpenAPITools:master Jun 3, 2021
@rm3l rm3l deleted the fix/9328_validatetask_gradle_7 branch June 4, 2021 07:06
@wing328 wing328 changed the title fix(#9328): Gradle Plugin ValidateTask does not work under Gradle 7.0 Fix Gradle Plugin ValidateTask not working under Gradle 7.0 Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] ValidateTask does not work under Gradle 7.0
3 participants