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

WireMock config changes are taken into account for live-reload (dev mode only) #85

Merged
merged 1 commit into from
Jan 27, 2024

Conversation

chberger
Copy link
Contributor

@chberger chberger commented Jan 8, 2024

This PR makes the Live Reload feature of Quarkus Dev Mode aware of WireMock config changes. However, the implementation has some limitations:

  • The file modification gets only recognized after a http request. --> Fits naturally to the WireMock usage model
  • A manual app restart is required when adding a new config file at runtime

@chberger chberger force-pushed the feature/live-reload-wiremock-config branch from 04f04a7 to 7bffb19 Compare January 11, 2024 23:03

@GET
@Path("/reload")
public Response reload() {

Choose a reason for hiding this comment

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

Should be added to the docs too, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I don't get your point. It's just an endpoint for testing purposes. What's your intention to add this to the doc?

@BuildStep(onlyIf = { WireMockServerEnabled.class, GlobalDevServicesConfig.Enabled.class, IsDevelopment.class })
void watchWireMockConfigFiles(WireMockServerBuildTimeConfig config,
BuildProducer<HotDeploymentWatchedFileBuildItem> items) {
listFiles(Paths.get(config.filesMapping(), MAPPINGS), Paths.get(config.filesMapping(), FILES)).forEach(file -> {

Choose a reason for hiding this comment

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

According to https://quarkus.io/guides/all-builditems , HotDeploymentWatchedFileBuildItem actually supports passing a Glob pattern, hence you could probably instruct it to watch all files under the Mappings and Files directories (including when new ones added?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've analyzed the glob-pattern feature back in the days. However, it does not convince me since the API is not very intuitive. Furthermore, it also doesn't work for new files (please see quarkusio/quarkus#25338). Anyway, the current implementation already watches all files under the Mappings and Files directories.

@oleg-nenashev
Copy link

Sorry for delay, new job onboarding :(

@chberger
Copy link
Contributor Author

Sorry for delay, new job onboarding :(

Don't worry, I am very grateful that you are doing a review at all. 😄

@chberger
Copy link
Contributor Author

@oleg-nenashev: Any further feedback? Otherwise I would release the feature soon.

@oleg-nenashev
Copy link

Hi. I didn't have a chance to review it yet, was snowed under the onboarding stuff at Gradle. I do not see anything wrong so I would just ship it

@chberger chberger merged commit 0004a47 into main Jan 27, 2024
1 check passed
@chberger chberger deleted the feature/live-reload-wiremock-config branch January 27, 2024 15:41
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