2009/5/11 Todd Thiessen <[email protected]> > > > Are there many cases where you want something for compilation > > that isn't needed at runtime? I don't see them as being separate. > > Really? I am surprised. Yes there is a relation between compile and > runtime. However, there is a different relation between compile and > test. Scope has multiple meanings here. You have scope which defines > when a dependency is needed (ie: at compile or runtime); or scope that > defines what code a dependency is needed for (ie: test or main). Really, > test scope means compile time (the when dimension of scope) for test > code (the what code dimension of scope). > > For instance, how does one define a test dependency that is only needed > at runtime? Two different concepts stored in one variable makes this > cumbersome.
I think the answer here is that nobody had a good example at the time! The primary issue that people want to control scope for is to ensure that: 1. They do not accidentally add compile time dependencies to implementations of an API (this may be stated in different ways) so for example, if I depend on the servlet-api I do not want to reference tomcat classes from my code because I have broken portability of my code hence the three scopes: compile - put on compile and runtime classpaths. provided - put on compile classpath only runtime - put on runtime classpath only The secondary issue is unit tests, we often need additional dependencies for writing unit tests that we don't want to creep into our (non-test) code. Also it can be useful to use GPL code when writing unit tests, although you might not use the GPL code in your (non-test) code. Thus enter test - put on test classpath I agree that perhaps we should separate the two sets of classpaths, i.e. the (non-test) compile and runtime classpaths and the test compile and runtime classpaths. But the pollution of runtime dependencies into test code is less of an issue for unit tests.... Integration tests should go in their own module and that gives you control over the compile and runtime classpaths of that code
