@@ -107,7 +107,7 @@ class GrailsApp extends SpringApplication {
107107
108108 if (location) {
109109 directoryWatcher = new DirectoryWatcher ()
110- configureDirectoryWatcher(directoryWatcher, location)
110+
111111 Queue<File > changedFiles = new ConcurrentLinkedQueue<> ()
112112 Queue<File > newFiles = new ConcurrentLinkedQueue<> ()
113113
@@ -141,6 +141,10 @@ class GrailsApp extends SpringApplication {
141141 }
142142 }
143143
144+ for (dir in watchBaseDirectories) {
145+ configureDirectoryWatcher(directoryWatcher, dir. absolutePath)
146+ }
147+
144148 def locationLength = location. length() + 1
145149
146150 for (GrailsPlugin plugin in pluginManager. allPlugins) {
@@ -239,8 +243,15 @@ class GrailsApp extends SpringApplication {
239243 protected void recompile (File changedFile , CompilerConfiguration compilerConfig , String location ) {
240244 File appDir = null
241245 def changedPath = changedFile. path
242- if (changedPath. contains(' /grails-app' )) {
243- appDir = new File (changedPath. substring(0 , changedPath. indexOf(' /grails-app' )))
246+
247+ String grailsAppDir = " ${ File.separator} grails-app"
248+ String sourceMainGroovy = " ${ File.separator} src${ File.separator} main${ File.separator} groovy"
249+
250+ if (changedPath. contains(grailsAppDir)) {
251+ appDir = new File (changedPath. substring(0 , changedPath. indexOf(grailsAppDir)))
252+ }
253+ else if (changedPath. contains(sourceMainGroovy)) {
254+ appDir = new File (changedPath. substring(0 , changedPath. indexOf(sourceMainGroovy)))
244255 }
245256 def baseFileLocation = appDir?. absolutePath ?: location
246257 compilerConfig. setTargetDirectory(new File (baseFileLocation, BuildSettings . BUILD_CLASSES_PATH ))
0 commit comments