From 0ad64b571c16cc7dc3b916930716fcf10a2fa52e Mon Sep 17 00:00:00 2001 From: Artem Kozlov Date: Thu, 9 May 2024 13:25:57 +0300 Subject: [PATCH] Support folders under "src/resources" in fastReload conifguration property. When hotreload is enabled gretty watches and always recompile/redeploy webapp if there are any change "src/java" or "src/resources". That is inconvenient when changing static resources in "src/resources" that don't require recompilation/redeploy. Workaround is to specify such folders under `src/resources` as fastReload. This change makes sure that fastReload check is performed before recompile check for sources. --- .../org/akhikhl/gretty/scanner/BaseScannerManager.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/gretty/src/main/groovy/org/akhikhl/gretty/scanner/BaseScannerManager.groovy b/libs/gretty/src/main/groovy/org/akhikhl/gretty/scanner/BaseScannerManager.groovy index 1684f0751..5f3ea7cfe 100644 --- a/libs/gretty/src/main/groovy/org/akhikhl/gretty/scanner/BaseScannerManager.groovy +++ b/libs/gretty/src/main/groovy/org/akhikhl/gretty/scanner/BaseScannerManager.groovy @@ -188,7 +188,10 @@ abstract class BaseScannerManager implements ScannerManager { }.each { wconfig -> log.info 'changed file {} affects project {}', f, wconfig.projectPath def proj = project.project(wconfig.projectPath) - if(proj.sourceSets.main.allSource.srcDirs.find { f.startsWith(it.absolutePath) }) { + if(ProjectReloadUtils.satisfiesOneOfReloadSpecs(f, fastReloadMap[proj.path])) { + log.info 'file {} is in fastReload directories', f + reloadProject(wconfig.projectPath, 'fastReload') + } else if(proj.sourceSets.main.allSource.srcDirs.find { f.startsWith(it.absolutePath) }) { if(wconfig.recompileOnSourceChange) { reloadProject(wconfig.projectPath, 'compile') // restart is done when reacting to class change, not source change @@ -219,9 +222,6 @@ abstract class BaseScannerManager implements ScannerManager { reloadProject(wconfig.projectPath, 'compile') webAppConfigsToRestart.add(wconfig) } - } else if(ProjectReloadUtils.satisfiesOneOfReloadSpecs(f, fastReloadMap[proj.path])) { - log.info 'file {} is in fastReload directories', f - reloadProject(wconfig.projectPath, 'fastReload') } else { log.info 'file {} is not in fastReload directories, switching to fullReload', f reloadProject(wconfig.projectPath, 'compile')