On Apr 18, 2009, at 12:45 PM, Jeppe Nejsum Madsen wrote:
On Sat, Apr 18, 2009 at 12:03 PM, Hans Dockter <[email protected]>
wrote:
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
...
}
Thanks for the quick response! I'm still not sure why jetty-util is
a first level dependency of my project. I don't reference anything
from it, only indirectly via the Server class found in jetty. Not
sure if this is related to the fact that I'm' using the scala
plugin to build. The pom.xml for my project only references jetty,
not jetty-util so maven seems to be able to figure it out, but maybe
it's actually the maven-scala plugin that does things differently?
Thanks for the feedback. Could you file a Jira with this use case?
- Hans
--
Hans Dockter
Gradle Project lead
http://www.gradle.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email