@@ -120,6 +120,11 @@ class GrailsApp extends SpringApplication {
120120 @Override
121121 void onNew (File file , List<String > extensions ) {
122122 changedFiles << file. canonicalFile
123+ // For some bizarro reason Windows fires onNew events even for files that have
124+ // just been modified and not created
125+ if (System . getProperty(" os.name" ). toLowerCase(). indexOf(" windows" ) != -1 ) {
126+ return
127+ }
123128 newFiles << file. canonicalFile
124129 }
125130 })
@@ -129,7 +134,7 @@ class GrailsApp extends SpringApplication {
129134 directoryWatcher. addListener(pluginManagerListener)
130135
131136 File baseDir = new File (location). canonicalFile
132-
137+ String baseDirPath = baseDir . canonicalPath
133138 List<File > watchBaseDirectories = [baseDir]
134139 for (GrailsPlugin plugin in pluginManager. allPlugins) {
135140 if (plugin instanceof BinaryGrailsPlugin ) {
@@ -155,8 +160,18 @@ class GrailsApp extends SpringApplication {
155160 boolean first = true
156161 for (watchBase in watchBaseDirectories) {
157162 if (! first) {
158- // the base project will already been in the list of watch patterns, but we add any subprojects here
159- plugin. watchedResourcePatterns. add(new WatchPattern (directory : watchBase, extension : wp. extension))
163+ if (wp. file != null ) {
164+ String relativePath = wp. file. canonicalPath - baseDirPath
165+ File watchFile = new File (watchBase, relativePath)
166+ // the base project will already been in the list of watch patterns, but we add any subprojects here
167+ plugin. watchedResourcePatterns. add(new WatchPattern (file : watchFile, extension : wp. extension))
168+ }
169+ else if (wp. directory != null ) {
170+ String relativePath = wp. directory. canonicalPath - baseDirPath
171+ File watchDir = new File (watchBase, relativePath)
172+ // the base project will already been in the list of watch patterns, but we add any subprojects here
173+ plugin. watchedResourcePatterns. add(new WatchPattern (directory : watchDir, extension : wp. extension))
174+ }
160175 }
161176 first = false
162177 if (wp. file) {
@@ -202,7 +217,8 @@ class GrailsApp extends SpringApplication {
202217 def changedFile = uniqueChangedFiles[0 ]
203218 changedFile = changedFile. canonicalFile
204219 // Groovy files within the 'conf' directory are not compiled
205- if (changedFile. path. contains(' /grails-app/conf/' )) {
220+ String confPath = " ${ File.pathSeparator} grails-app${ File.pathSeparator} conf${ File.pathSeparator} "
221+ if (changedFile. path. contains(confPath)) {
206222 pluginManager. informOfFileChange(changedFile)
207223 }
208224 else {
0 commit comments