Skip to content
Resource augmentation for grails
Groovy Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This plugin provides the possibility to extend any textual resource with any other resources - all via some simple configuration values.


Just add

compile: ":augmented-resources:1.0"

to the plugins section of your BuildConfig.goovy and you are good to go.


Imagine you have to build a grails application which has to support certain styling customizations (eg. adaption of colors to comply with a certain CI). This is easily done with the help of this plugin! Just do your initial styling with a css preprocessor like less and define everything you want to be customizable in variables - eg some color like @font-color, @background-color, etc. In addition just add some minor configurations like that:

grails.resources.mappers.augment.lesscsscompatibility = true
grails.resources.mappers.augment.augment = [
    'less/main.less' : [
            append: "${['catalina.base']}/style/ci_modifications.less"

Now you can deploy your application with a default style which works out of the box, but probably doesn't really integrate very well with most CIs. The configured file (in our case /style/ci_modifications.less within the tomcat directory) doesn't have to exist - the plugin just doesn't do anything in that case. But as soon as you provide that particular file it is appended to your main.less file - providing you with the possibility to override any variable definitions and add new selectors which all have full access to all available variables and mixins you have defined in your application. By doing so you can easily provide a customized look & feel within a few minutes - all you need to do is create a single file and restart your server.


  • add content to any text based resource (eg. js, css, less, etc.) via simple configuration
  • choose between prepending and appending the content to the file - or do both!
  • specify resources to augment with ant patterns
  • use either local files or arbitrary resources as source for your augmentation


The following configurations are supported:


A list of ant patterns of all resources to include into the augmentation process. Defaults to ['less/**/*.less, 'css/\*/*.css', 'js/**/*.js']


A list of ant patterns of all resources for exclude form the augmentation process. Empty by default


If true all augmented .less files will update the sourceUrl to enable processing by the lesscss plugin


A map containing the configuration on which resources to augment with which files. The keys of the map are ant patterns against all resources which are included for processing are matched. The values again are a map which can contain values for 'prepend' (prepend to the resource) and 'append' (append to the resource). Following is a list (or single element) of either Resources (eg. UrlResource, FileSystemResource, ClasspathResource, etc.) or simple Strings refering to the path of the file.

This leads to the following structure:

    '<<antPattern>>' : [
        prepend: ['<<ResourceOrPath>>'],
        append: ['<<ResourceOrPath>>']


grails.resources.mappers.augment.lesscsscompatibility = true
grails.resources.mappers.augment.augment = [
    '**/*.less' : [
        prepend: [
            new UrlResource(""),
            new UrlResource(""),
    'less/main.less' : [
        append: [
            new UrlResource("${appName}/${appVersion}/append/main.less")
    '**/*.js' : [
        prepend: 'js/license.js'


  • the contents of the original files are copied and saved as a completly new file - therefore relative references will not work! (eg. in the usage example above you cant put ci_colors.less next to the ci_modifications.less and add a @import "ci_colors.less" to your file - it just wouldn't work!


  • get rid of 'grails.resources.mappers.augment.lesscsscompatibility'
Something went wrong with that request. Please try again.