Search code examples
grailsgradleasset-pipelinegrails-plugin

Grails 3 "Build failed with an exception" using assets-pipeline with sass-grails-asset-pipeline


I'm trying to use the grails asset-pipeline plugin with the sass extension on Grails 3. Unfortunately, following the documentation to configure them in the build.gradle file isn't useful because this error is generated:

FAILURE: Build failed with an exception.

* Where:
Build file '/MyProject/build.gradle' line: 17

* What went wrong:
Could not compile build file '/MyProject/build.gradle'.
> startup failed:
  build file '/MyProject/build.gradle': 17: only id(String) method calls allowed in plugins {} script block

  See http://gradle.org/docs/2.3/userguide/plugins.html#sec:plugins_block for information on the plugins {} block

   @ line 17, column 5.
         provided ":sass-asset-pipeline:$assetsPipelineSassVersion"
         ^

  1 error


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.128 secs
| Error Error initializing classpath: startup failed:
build file '/MyProject/build.gradle': 17: only id(String) method calls allowed in plugins {} script block

See http://gradle.org/docs/2.3/userguide/plugins.html#sec:plugins_block for information on the plugins {} block

 @ line 17, column 5.
       provided ":sass-asset-pipeline:$assetsPipelineSassVersion"
       ^

1 error
 (Use --stacktrace to see the full trace)
0

Solution

  • I've found a solution with this gradle configuration (version variables are defined in gradle.properties):

    buildscript {
        dependencies {
            classpath "com.bertramlabs.plugins:asset-pipeline-gradle:$assetsPipelineVersion"
        }
    }
    
    apply plugin: 'com.bertramlabs.asset-pipeline'
    
    
    assets {
        minifyJs = true
        minifyCss = true
        from '/img'
        from '/js'
        from '/css'
        from '/fonts'
    }
    
    dependencies {
        compile "org.grails.plugins:asset-pipeline"
    
        runtime "org.grails.plugins:asset-pipeline"
        assets "com.bertramlabs.plugins:sass-asset-pipeline:$assetsPipelineSassVersion"
    }