0

I'm about to deploy my Grails 3 web-app using gradle assemble to create the war file, and I'm trying to exclude a few jar files from it.

In particular I added in my build.gradle configuration file

dependencies {
    [...]
    assets 'com.bertramlabs.plugins:sass-asset-pipeline:2.7.2'
}

These are the internal dependencies for the above plugin, which helps me to process SASS files into CSS

 \--- com.bertramlabs.plugins:sass-asset-pipeline:2.7.2
      +--- com.bertramlabs.plugins:asset-pipeline-core:2.7.2
      |    +--- org.mozilla:rhino:1.7R4
      |    +--- com.google.javascript:closure-compiler:v20151015
      |    \--- commons-logging:commons-logging:1.1.1
      +--- log4j:log4j:1.2.17
      +--- org.jruby:jruby-complete:1.7.11 -> 1.7.18
      \--- com.bertramlabs.plugins:jruby-container:0.6.1
           \--- org.jruby:jruby-complete:1.7.18

I excluded the org.ruby group as the jar is 22MB and is not needed in production as the assemble task already bundles my css resources.

configurations {
    compile.exclude group: 'org.jruby'
    [...]
}

This works for production environment but the dependency is instead needed for development.

Is there a quick way to achieve this? Thanks in advance!

ilPittiz
  • 734
  • 1
  • 10
  • 23

2 Answers2

1

i have not tested this yet. In build.gradle in dependencies put

if (!project.hasProperty('grailsEnv') || project.grailsEnv.equals('dev')) { compile.exclude group: 'org.jruby' }
Arjang
  • 731
  • 1
  • 10
  • 19
  • I didn't know something like `project` was included in the scope, this helped me a lot! Unfortunately there's no `grailsEnv` property, but after a few attempts I came up with a solution (answer added). – ilPittiz Mar 11 '16 at 10:36
  • Thanks for the solution. I saw my solution in [here](http://www.grailsbrasil.com.br/post/show/2972). – Arjang Mar 11 '16 at 11:50
1

Thanks to Arjang suggestion this solved my problem (though I'm sure there must me some other solution)

assets ("com.bertramlabs.plugins:sass-asset-pipeline:2.7.2") {
    if(project.gradle.startParameter.taskNames.contains('assemble')) {
        exclude group: 'org.jruby'
    }
}
ilPittiz
  • 734
  • 1
  • 10
  • 23