I am developing a grails application. I want the browser page to refresh the changes/edits in code on the fly without manually hitting the refresh button everytime. I tried LiveReload but couldn't get it working with the grails server. Is there any other application for this purpose? I use Intellij Idea IDE for coding.
What does Grails do:
Grails automatically recompiles changes made to Java & Groovy source code. It can, by using the correct plugins, also automatically recompile Less, Sass, … files.
What does LiveReload do:
LiveReload monitors files & folders on your file system and signals a browser to refresh when one of the monitored files change.
How to combine both:
Configure LiveReload to monitor different sub folders of your Grails project. Add the different Grails resources (views, web-app/js, web-app/css, src/groovy, … ) as separate monitored folders. You also do not want liveReload to compile Less, Sass, CoffeeScript, … resources since Grails handles the recompilation.
Recompilation of resources by Grails can take some time, so we want to configure the waiting time for each resource in LiveReload accordingly. Otherwise the browser would refresh before the changed resources are made available by Grails.
For example for my folder with Less files the waiting time is set to 4 seconds, since recompiling most Less files takes at least a few seconds. The waiting time for my folder with js files is set to 1 second. It takes some experimentation to find the optimal settings for your project and system.
Related
I just recently switched from using the outdated cfx to jpm for developing my Firefox add-ons. Every time I make a change to my code and want to test it again, I have to use the "jpm run" command it literally takes 3 to 5 minutes to launch the browser with the new code inside. This makes it pretty much impossible to develop my add-on because, every time I want to test a new line of code, I have to wait several minutes.
This kind of problem doesn't occur in Chrome so I'm not sure what the people at Mozilla are thinking. Do they want to make it nearly impossible to develop add-ons for their browser?
What are other Firefox add-on developers doing to test their code? Do they just spend hours launching and relaunching the browser very very slowly? Or is there a workaround?
You can use jpm watchpost together with the extension auto-installer instead to auto-reload the extension in a running firefox session.
But even without that it should not not take minutes, only seconds.
As the8472 has mentioned, you can test Add-on SDK extensions without the need to restart the browser using jpm by using jpm watchpost. Using this appears to take a bit of configuring. I have not used this, as I would find having the add-on automatically updated upon every write to a file a bit annoying. I often change multiple files, or make multiple writes to the same file between the times I run the add-on to test. Basically, I want to maintain more control as to when the add-on is reloaded than to have it automatically done each time a file is changed.
There is a way to load temporary add-ons which works for both unpacked add-ons and .xpi files. The problem is that prior to running jpm, your add-on is not actually a complete Firefox add-on. jpm adds wrappers around the contents of your add-on to make it a normal bootstrapped add-on. Without those wrappers, your add-on will not function. One possibility would be to run jpm xpi each time you want to test a new version: Once you have initially loaded the add-on as a temporary add-on, you would run jpm xpi, then click on the "Reload" button for your add-on in about:debugging.
[This method will have issues which you will need to work through]: Alternately, you could unpack the .xpi file and continue your development from the files contained in the resulting directories while using the temporary add-on method of installing your add-on (click on any file in the directory where you unpacked the files to install as a temporary add-on). However, this method may prevent you from using jpm at all with your add-on. In addition, jpm performs somewhat different actions when packaging your add-on into an .xpi file depending on the contents of your add-on. If so, things may start to break if you significantly change your add-on's functionality (e.g. changes in package.json won't propagate to install.rdf). With this method, you would, probably, need to use a "normal", non-jpm method of creating an .xpi file when you want to publish your add-on.
I have installed the spring security core plugin. I need to modify the login page to look like my existing website. I have searched the entire project and cannot find it. I am running grails 2.4 and spring-security-core:2.0-RC5. Where can this pesky little file be? Can someone who is not a complete greenhorn help a fellow out?
As #Abs points out, the file is at target/work/plugins/spring-security-core-2.0-RC5/grails-app/views/login/auth.gsp but you shouldn't edit plugin files. Other developers on your team won't have access to the modified files and if you delete the target directory you'll lose your changes since the target directory is only a temporary work location.
Instead, copy the file to the same relative location in your application and make changes there. Create grails-app/views/login and copy the file there and make whatever changes you want.
This technique works for most plugin files, not just GSPs. The compilation order and classpath are configured such that application files and classes override plugin files if they're in the same location/package.
You can find the default login page here
targt->work->plugins->spring-security-core-2.0-RC5->grails-app->views->login>auth.gsp
I have this Grails 2.2.3 (still...) application. It's a normal app using GORM, and SpringSecurity, nothing unusual.
The only unusual thing is when the app goes in production, the webapps/ROOT folder (where the app lives) is populated by a lot of other folders in the root of it. These folders do not contain stuff that is needed by Grails, but for reasons I find shameful ^_^; , they have to be there. I'm talking about a huge amount of directories with various depths.
The big problem here is at Tomcat restart, the whole process hangs with a beautiful:
INFO: Initializing Spring root WebApplicationContext
and takes like 40 minutes to proceed further.
Using JVisual, we noticed the reason was a huge amount of directory listing and file reads.
We never reproduced this behavior locally, until we noticed this thing. We recreated an environment full of directories and violà, same behavior.
Now:
anyone can confirm my guess is right
any idea on how I can "disable" this search on uninteresting paths (or tell which are interesting)
Ok, I can confirm this is actually happening. When Grails starts, it looks into its webapp directory and scans looking for something. If the directory is stuck with content, it'll hang forever.
We didn't find a solution to this problem but found a way to move those resources away from the folder.
So keep in mind: always keep your webapp directory clean form stuff that can be moved elsewhere.
I have a Grails 2.4.3 project. It is using angular and a good amount of external js libraries. Whenever, I try to create a war, it times out when attempting to minimized the js. I assumed it was because there are way too many libraries so I extended the timeout in GGTS, but it still timeout. I tried also exclude some the assets but it gave me null pointer exception at the beginning of the asset compilation. For now, I'm skipping the minify by setting it to false. Here are my questions:
Is there a problem having minimized js libraries already in the manifest?
Can I added the required libraries outside the manifest and get added to the war? like in web-app/js ?
I believe I could add the CDN in the html rather than having the libraries in the manifest and copied to my project, but sometimes, I worked without internet access. Is there a way to configure asset pipeline that for production to use CDN for certain assets?
The documentation covers all if not most of your questions.
config section
This section cover cdn and control of minimization
For instance
grails.assets.url = "http://cdn.example.com/"
Will set a cdn URL
I generated an Angular app and when I run grunt server it works (it shows the default page) but when I browse the files and double click index.html I get an empty page (except for the grey background).
Why is that? Isn't it just JS/CSS/HTML?
Depending on your setup some files usually need conversion- for instance your styles may well be in compass or SASS and need to be converted to regular css. Grunt handles all the various conversions you need (as well as launching the static page server).
Check out your console error log in the browser and I'll bet you'll see some "Failed to load resource" errors- for instance the css file may well not be there (when you're trying to run index.html directly).
By the way, you can run:
grunt build
This will create a new directory "dist" with everything converted and ready for distribution- sounds like this might be what you're looking for.