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

Allow running CLI in dev mode, without overwriting quarkus version #1232

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

mocenas
Copy link
Contributor

@mocenas mocenas commented Jul 30, 2024

Summary

Create an option for CLI based application to run and not have their quarkus version overwritten. Using up-to-date quarkus is usually a good thing, but for testing CLI stuff like --stream=3.x and quarkus update I want to run the app with the version that is specified in the pom and not overwrite it.

This PR should cause no problem to existing stuff, as defaults are the same. It just allows to change this behaviour to run quarkus apps without setting quarkus version as their parameter. Example how to use it is new test.

Please check the relevant options

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Dependency update
  • Refactoring
  • Release (follows conventions described in the RELEASE.md)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • This change requires a documentation update
  • This change requires execution against OCP (use run tests phrase in comment)

Checklist:

  • Example scenarios has been updated / added
  • Methods and classes used in PR scenarios are meaningful
  • Commits are well encapsulated and follow the best practices

@mocenas mocenas requested a review from fedinskiy July 30, 2024 14:13
Copy link
Contributor

@fedinskiy fedinskiy left a comment

Choose a reason for hiding this comment

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

There is one only thing (see below). I would prefer to have it changed, but it is not a blocker

.withStream("3.8")
.withPlatformBom(null)
.withManagedResourceCreator(
(serviceContext, quarkusCliClient) -> s -> new CliDevModeVersionLessQuarkusApplicationManagerResource(
Copy link
Contributor

Choose a reason for hiding this comment

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

This lambda is a bit hard to comprehend (especially since s parameter is not used). Please, consider, whether this api can be changed to improve readability

Copy link
Contributor Author

@mocenas mocenas Jul 31, 2024

Choose a reason for hiding this comment

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

I agree, this lambda is ugly. Thing is, it is two level lambda - basically a reduction for typical problem "how to fix a square thing into round hole". This lambda actually provides instance of ManagedResourceBuilder, which takes just one parameter(ServiceContext) but we need to instantiate CliDevModeLocalhostQuarkusApplicationManagedResource which has two parameters (ServiceContext, QuarkusCliClient).

I tried other approaches like some magic with OOP and interface inheritance or passing just class reference. All of them either hit some java limitation, or have really nasty implementation.

To conclude I found no better way how to solve this, that would not require greater changes in already existing stuff. I at least renamed "s" variable to managedResourceBuilder so it is somehow cleaner what is going on.

@mocenas mocenas merged commit be7a968 into quarkus-qe:main Jul 31, 2024
8 checks passed
@mocenas mocenas deleted the allow_versionless_CLI branch July 31, 2024 09:44
jcarranzan pushed a commit to jcarranzan/quarkus-test-framework that referenced this pull request Aug 5, 2024
…uarkus-qe#1232)

* Allow running CLI in dev mode, without overwriting quarkus version
@mocenas mocenas mentioned this pull request Aug 14, 2024
11 tasks
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