The maven defines several scopes for dependencies:
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
There is a "provided" scope:
" This scope is only available on the compilation classpath, AND IS NOT transitive."
Here we have 2 modules in IDEA project (in attachment).
module 1 (depends on "commons-io" with scope "provided")
module 2 (depends on module 1)
In module1, IDEA shows dependency on "commons-io" with unchecked "Export" flag, so "commons-io" dependency is not shown in dependency list for module 2. This is correct.
But if we run a class with classpath "module 2", the class path contains "commons-io" dependency, like this:
[code]
C:\bin\java\jdk\jdk1.6.0_01\bin\java -Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:4032,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "C:\bin\java\jdk\jdk1.6.0_01\jre\lib\charsets.jar;....;C:\bin\java\jdk\jdk1.6.0_01\jre\lib\ext\sunpkcs11.jar;D:\temp\deptest\module2\target\classes;D:\temp\deptest\module1\target\classes;C:\Documents and Settings\dima\.m2\repository\org\apache\commons\commons-io\1.3.2\commons-io-1.3.2.jar;C:\Program Files\JetBrains\IntelliJ IDEA 7.0.3\lib\idea_rt.jar" org.test1.SomeRun
[/code]
Please note "commons-io-1.3.2.jar" is included in classpath, although it is marked as "provided" in "module 1" , so shall not be transitive.
Since I DO need to exclude "commons-io" dependency, i've added to module 2 an exclusion from module1:
[code]
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
</exclusion>
</exclusions>
[/code]
But it does not help either.
Module "commons-io" is included in test classpath in any case.
So we can not remove module's transitive dependency from classpath.
If we remove "module 1" from the project, transitive dependencies work fine, but in our case we do need to work with "module 1" in out project
That is the practical problem with such configuration?