Rob Hruska
Rob Hruska

Reputation: 120286

How do I prevent Grails from auto-reloading certain files?

When using Emacs to edit a Grails source file, Emacs will temporarily create hidden write-lock files alongside the source file. For example, if editing com/example/MyController, one might see:

rob@machine:~/app$ ls -la grails-app/controllers/com/example/
total 28
drwxrwxr-x 3 rob rob 4096 2011-12-03 13:38 ..
-rw-rw-r-- 1 rob rob 3883 2012-01-03 13:57 MyController.groovy
lrwxrwxrwx 1 rob rob   26 2012-01-04 09:32 .#MyController.groovy -> [email protected]:1324674574

When this file gets created during a run-app, Grails notices it and tries to compile it, often yielding compilation errors in the run-app console logs:

| Error 2012-01-04 09:32:51,207 [Thread-38] ERROR plugins.AbstractGrailsPluginManager  - Plugin [controllers:2.0.0] could not reload changes to file [/home/rob/app/grails-app/controllers/com/example/.#MyController.groovy]: Dynamic method is<Artefact>Class(artefactClass) requires a single Class parameter
Message: Dynamic method is<Artefact>Class(artefactClass) requires a single Class parameter
   Line | Method
->> 629 | doCall in SpringSecurityCoreGrailsPlugin$_closure5

It's possible that this only happens when using the spring-security-core plugin, but I haven't tested it without the plugin installed.

I believe this only happens in Grails 2.0; I never observed it in 1.3.7 or earlier.

Is there any way to have Grails ignore these files when automatically recompiling during run-app? A general answer for controlling what files do and do not get reloaded would be ideal.

An authoritative answer of "no, this is not possible" is also acceptable to me. I understand that this may just not be possible via configuration, in which case I'll probably open a JIRA enhancement.

Upvotes: 2

Views: 991

Answers (1)

Andrew von Dollen
Andrew von Dollen

Reputation: 11

I haven't tried the patch, but it looks like this was recently addressed by Graeme:

https://github.com/grails/grails-core/commit/c201492dfa47419356fbfea2031d22755ea61fe9

Line 224 excludes files starting with a dot (ie. emacs write locks)

See also: http://jira.grails.org/browse/GRAILS-8539 which indicates that this could show up in 2.0.1

Upvotes: 1

Related Questions