On Apr 18, 2009, at 11:24 AM, Jeppe Nejsum Madsen wrote:
Hi,
I'm new to the world of dependency management, so the following
might be obvious, but I couldn't figure out how to do it.
I need to have some tests that depend on jetty, so I add this to
build.gradle:
addMavenRepo()
testCompile 'org.mortbay.jetty:jetty:6.1.6',
But compilation fails with
error: error while loading Server, class file 'C:\Users\jnm\.gradle
\cache\org.mortbay.jetty\jetty\jars\jetty-6.1.
6.jar(org/mortbay/jetty/Server.class)' is broken
(class org.mortbay.util.Attributes not found.)
Looking at http://repo2.maven.org/maven2/org/mortbay/jetty/jetty/6.1.6/jetty-6.1.6.pom
,
I can see jetty depends on jetty-util, and adding this to
build.gradle fixes the build:
testCompile 'org.mortbay.jetty:jetty-util:6.1.6'
But I thought the whole purpose of dependency management was to
avoid adding all the transitive dependencies manally? I'm complete
wrong on this or is there another explanation for what I'm seeing?
There is another explanation. One important aspect of dependency
management is to make it expressive what are your first level
dependencies and what are transitive dependencies. In the example
above jetty-util is a transitive dependency of jetty but also a first
level dependency of your project. The Gradle default is to force you
to express explicitly your first level dependencies (see also UG
17.1.2: http://gradle.org/userguide/latest/
dependency_management.html). We do this by letting the compile and
testCompile configuration return only the first level dependencies (in
contrast to testRuntime for example). To let Gradle use also the
transitive dependencies for compile simply declare:
dependencies {
testCompile.transitive = true
...
}
- Hans
--
Hans Dockter
Gradle Project lead
http://www.gradle.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email