Pither.com / Simonhttps://www.pither.com/simon/blog/2013-07-29T13:55:48+00:00Development, systems administration, parenting and businessDependency excludes in Grails 1.22010-02-01T00:00:00+00:002013-07-29T13:55:48+00:00Simon Pitherhttps://www.pither.com/simon/blog/2010/02/01/dependency-excludes-in-grails-1.2<article>
<h1>Dependency excludes in Grails 1.2</h1>
<div class="article-meta">
Posted
by <span>Simon Pither</span>
on <time datetime="2010-02-01T00:00:00+00:00">Mon 1st Feb 2010</time>
(updated <time datetime="2013-07-29T13:55:48+00:00">Mon 29th Jul 2013</time>)
</div>
<div>
<p>I ended up reading the Grails code to figure this out, so I thought it might be useful to record.</p>
<p>One of the projects that I recently upgraded to <a href="http://grails.org/">Grails 1.2</a> makes use of <a href="http://groovy.codehaus.org/HTTP+Builder">Groovy HTTP-Builder</a>. If you just pull in HTTP-Builder you'll quickly find that it's dependencies break your grails project. So under 1.1.1 and using maven, I had this:</p>
<pre><code><dependency>
<groupId>org.codehaus.groovy.modules.http-builder</groupId>
<artifactId>http-builder</artifactId>
<version>0.5.0-RC1</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
</code></pre>
<p>New in Grails 1.2 is <a href="http://grails.org/doc/latest/guide/3.%20Configuration.html#3.7 Dependency Resolution">dependency management</a> via conf/BuildConfig.groovy. There are lots and lots of examples around for how to define dependencies, but significantly less on how to exclude dependencies of those dependencies. So here's mine:</p>
<pre><code>dependencies {
compile('org.codehaus.groovy.modules.http-builder:http-builder:0.5.0-RC1') {
excludes 'groovy', 'xml-apis'
}
}
</code></pre>
<p>The thing that caught me out was that there's no groupId specified on the excludes, only an artifactId.</p>
<p>Something else I noticed while reading the dependency code was that the dependency string matching is very limited. Only three parts (groupId:artifactId:version) can be matched. None of the other (ie type or classifier) maven parameters are supported.</p>
</div>
<div class="tags-panel panel panel-default">
<div class="panel-body">
Tags:
<a rel="tag" href="/simon/blog/?tag=grails">grails</a>
<a rel="tag" href="/simon/blog/?tag=dependencies">dependencies</a>
<a rel="tag" href="/simon/blog/?tag=technology">technology</a>
</div>
</div>
</article>