I am new to maven . I have a project which is using Maven 3 and Jdk 6 . I am not able to understand why maven is trying to look for the transitive dependency at the compile time itself.
For example , I have a Project P which has dependency A (JAR file) and A Jar is using some classes from B Jar , means A is dependent on B.
That implies that P is transitively dependent on B. (P -->A-->B)
Now when Project P is being compiled (mvn compile ) , its giving Compile time errors saying that some of the symbols are not resolved (that is classes from B JAR are not available ).
My question is why this issue is coming at the compile time itself , this should be the run time Error ?.
Is maven smart enough to read the dependent JAR's bytecode (JAR A) and resolve its dependencies (JAR B) at the compile time of Project P itself.
Transitive dependencies are included at compile time because they might be needed to support deeply nested class hierarchies. For example, class C extends B, class B extends A. Each class is in a separate (c.jar, b.jar and a.jar). Your app creates another class that extends class C, so you place c.jar in your dependencies. But that is insufficient for the compiler to determine what your class looks like. Thus Maven includes the transitive dependencies to "fix" this issue. (Personally, I would preferred that in this case that Maven would require you to include a.jar, b.jar and c.jar in your dependency list.)
Though reading you post again, it doesn't look like you are getting a Maven error (hard to say for sure since you didn't post the exact error message you are seeing, paraphrasing error message is always a bad idea) but rather a compiler error message. The above still applies - the compiler needs all of the superclass information to construct object layouts.