Grails copy resources to external dir - grails

I would like to copy all the resources (js, css, bundles) created from grails (and its plugins cache, gzip, etc..) into an external folder (in S3) instead of inside the war.
Is it possible?
I've tried to check inside the documentation but with no result...

You can use grails.war.resources to customize war content. Take a look at section 18 of grails manual.

Related

Grails Serve Static Contents from WebServer from ApplicationResources.groovy

We have a web server for static files (css/js/images). We obtain the war from the Grails command and delete the static web-app contents from application (in build.xml). I thought resources will be redirected to static/js/ or static/css/ but it complains that js/ or /css/ cannot be found.
We don't want to have duplicates under application and web-server. How to force Grails to look at external directory in ApplicationResources.groovy?
The Web server overrides static contents only if files are already present under Application.
Use below configuration in Config.groovy:
grails.resources.work.dir = "path/for/static/assets/in/web/server"
Refer the configuration page of resources plugin for details. However, in future, if you decide to migrate to use asset-pipeline plugin instead of resources plugin then use below configuration:
grails.assets.url = "path/for/static/assets/in/web/server"
Refer docs for details.

Grails asset-pipeline custom theme support

I'm trying to implement theme from external developers in grails using asset-pipeline plugin
theme structure:
-css
--patterns
--plugins
--animate.css
--bootstrap.css
...
-js
--plugins
--bootstrap.js
...
-img
-font-awesome
--css
--fonts
--less
--scss
...
If I import all files in appropriative directories of assets (stylesheets, javascript, images) many problem arise, ex:
-project/img/sample.jpg not found
-assets/bootstrap.css.map 404 (Not Found) (there is no such file)
and variuos js errors
when I use resource plugins and keep theme's folders structure everything works fine
So my question is how to use asset-pipeline with predefined theme?
Solved with using <asset:javascript src="xx.js" /> for each entry in order of source page

Web fragments (Servlet API 3.0) - Also modular resources in WEB-INF directory

According to Servlet 3.0, a JAR placed in WEB-INF/lib has static content from its META-INF/resource directory accessible from the web-context root.
The specification doesn't say anything about modular resources, which should be accessible from the WEB-INF directory.
I would like to create a modular project, where every module "adds" all files from its WEB-INF directory to the web-context/WEB-INF directory. Is it possible?
OK I understand.. Simply create a folder META-INF/resources/WEB-INF :)

Grails Config: include another config file

I have in my main config something like:
grails.config.locations = ["file:grails-app/config/Jawr.groovy"].
When running the application with grails run-app, everything is OK.
But, on deployment (creating the war archive) this does not work anymore, as the file "Jawr.groovy" is not kept anymore on the filesystem (it should be only in the war).
Do you have a solution for that? Hw do you include external files into the grails main configuration file?
Thanks.
Okay, a few things here.
First, because you don't have a leading slash on your config path, that is a path relative to who knows where. I played with this in Tomcat, and that path ends up being relative to the working directory you were in when starting the Tomcat server. If you start Tomcat, shut it down, change directories, then start it again, you are going to get two different config paths.
Second, the grails-app directory only exists within the source tree of your Grails project. The structure of an unpacked WAR file is more like the web-app folder of your Grails source tree, with folders like WEB-INF, META-INF, js, images, etc.
Third, you probably want to avoid putting your externalized config file inside the folder of your webapp. The next time you deploy your app, that configuration is going to get wiped away with the old version of the app. One of the points of the externalized config is so that you can redeploy without having to reconfigure.
A simple, but less than ideal, solution would be to use a static, fully qualified path, like /etc/yourApp/conf.groovy, then put that in the documentation. There is also a plug-in that handles this.
http://www.grails.org/plugin/external-config
I haven't used it, but the description makes it sound like it does sensible things.
see this: https://stackoverflow.com/questions/6341117/is-it-possible-that-grails-xxconfig-groovy-as-a-script-no-compile
Then I put it into /shared, and
modify:
//Config.groovy
grails.config.locations =
["file:shared/TZLibConfig.groovy"]
//BuildConfig.groovy
grails.war.resources = { stagingDir, args ->
copy(todir: "${stagingDir}/WEB-INF/shared"){
fileset(dir:"shared",includes:"**")
}
}
In my work, our team often use a system properties to save the path to the config file (often in home folder of the user running the app - for privilege sake). Then we manually copy the config file into that path
To identify that it's the production environment, we use the following code in Config.groovy:
if (System.properties["${appName}.config.location"]) {
grails.config.locations = ["file:" + System.properties["${appName}.config.location"]]
}
This article suggests allowing the user to specify the location of the config file as an environment variable or as a java property --- meaning you can simply specify it with -D on the command-line. This can be used in addition to all the other methods.

compass.cfg.xml path in grails project with searchable plugin

I installed searchable in my grails project. As I already had the java POJO classes I want to use compass for the mapping customisation.
However, it seams that the Searchable.groovy looks for a file compass.cfg.xml at the root of my classpath. This folder is my PROJECT_HOME folder. I also tried to put him at /src/java
or in grails-app folder but the the file is not found => compass cannot start!
Is there a way to customize the path of the compass.cfg.xml?
PS: I run my project with run-app!
For the plug in to find it, it needs to be in the classpath so if you put it under grails-app/conf it should find it with no problem, I have used it like this before.

Resources