Skip to content

Commit

Permalink
Prefer classes dir for hot deployment of static resources
Browse files Browse the repository at this point in the history
The original resources without Maven properties resolution were provided by
Static Handler for `src/main/resources/META-INF/resources` files when running
in dev mode. The strategy used for hot deployment doesn't consider the resources
filtering. So the interpolation of Maven properties wasn't processed.

Resolves #15303
  • Loading branch information
brunolmfg committed Feb 25, 2021
1 parent d153f86 commit 42b633c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public RuntimeUpdatesProcessor(Path applicationRoot, DevModeContext context, Cla
public Path getClassesDir() {
//TODO: fix all these
for (DevModeContext.ModuleInfo i : context.getAllModules()) {
return Paths.get(i.getResourcePath());
return Paths.get(i.getClassesPath());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ public class StaticResourcesHotReplacementSetup implements HotReplacementSetup {
@Override
public void setupHotDeployment(HotReplacementContext context) {
List<Path> resources = new ArrayList<>();
addPathIfContainsStaticResources(resources, context.getClassesDir());
for (Path resourceDir : context.getResourcesDir()) {
Path resource = resourceDir.resolve(StaticResourcesRecorder.META_INF_RESOURCES);
if (Files.exists(resource)) {
resources.add(resource);
}
addPathIfContainsStaticResources(resources, resourceDir);
}
StaticResourcesRecorder.setHotDeploymentResources(resources);
}
Expand All @@ -31,4 +29,12 @@ public void handleFailedInitialStart() {
public void close() {
StaticResourcesRecorder.setHotDeploymentResources(null);
}

private void addPathIfContainsStaticResources(List<Path> resources, Path resourceDir) {
Path resource = resourceDir.resolve(StaticResourcesRecorder.META_INF_RESOURCES);
if (Files.exists(resource)) {
resources.add(resource);
}
}

}

0 comments on commit 42b633c

Please sign in to comment.