title: Play 2.0 / SBT: Exclude certain transitive dependencies from some/all modules in Build.scala
body: <p>I have a large legacy Java application with a Grails front end, and I'm working on replacing the Grails front end with a new one written in Play. Some of the (Maven) module dependencies in the legacy Java bring in problematic/conflicting things. Sorting out all the legacy Java dependencies isn't really an option at this point, so I'd like to just exclude the transitive dependencies I don't like.</p>
  
  <p>In Grails <code>BuildConfig.groovy</code>, I can define a list of exclusions:</p>
  
  <pre><code>def some_bad_things = [
          [group: 'some-evil-group'],
          [name: 'some-evil-module-from-another-group'],
          [name: 'some-other-evil-module']
  ]
  </code></pre>
  
  <p>and then use it for a whole block of direct dependencies:</p>
  
  <pre><code>dependencies {
      compile (
          [group: 'com.foo', name: 'foo-module1', version: '1.0'],
          // ... 20 or 30 modules ...
          [group: 'com.quux', name: 'quux-module42', version: '7.2'],
      ) {
          excludes some_bad_things
      }
  }
  </code></pre>
  
  <p>It's not obvious what the <code>Build.scala</code> syntax is for doing the same thing. Translating the actual dependencies is pretty straightforward ...</p>
  
  <pre><code>val appDependencies = Seq(
      "com.foo" % "foo-module1" % "1.0" % "compile",
      // ... 20 or 30 modules ...
      "com.quux" % "quux-module42" % "7.2" % "compile"
  )
  </code></pre>
  
  <p>... but the exclusions aren't; it looks like I have to exclude everything individually:</p>
  
  <pre><code>val appDependencies = Seq(
      ("com.foo" % "foo-module1" % "1.0" % "compile"),
          .exclude("some-evil-group", "evil-module-1")
          .exclude("some-evil-group", "evil-module-2")
          .exclude("mostly-ok-group-1", "some-evil-module-from-another-group")
          .exclude("mostly-ok-group-2", "some-other-evil-module"),
  
      // ... 20 or 30 modules, each with four excludes ...
  
      ("com.quux" % "quux-module42" % "7.2" % "compile")
          .exclude("some-evil-group", "evil-module-1")
          .exclude("some-evil-group", "evil-module-2")
          .exclude("mostly-ok-group-1", "some-evil-module-from-another-group")
          .exclude("mostly-ok-group-2", "some-other-evil-module")
  
  )
  </code></pre>
  
  <p>I assume there isn't a lot of rocket science going on here, and even if there's no out of the box way to globally exclude, it shouldn't be hard to write some helper function, or something, that would do it for me. But I'm a Scala newbie and it's not even obvious to me what types I'm looking at or what all the operators do, or how much of what I'm seeing is plain Scala / SBT and how much is Play-specific. So, suggestions welcome?</p>