Maven : what is the "runtime" scope purpose?

Maven

Maven Problem Overview


> Possible Duplicate:
> Understanding Compile- vs Run-time Dependencies

I understand that a dependency with the "runtime" scope will be available at runtime and not at compile time. But I don't understand why you could want that! Why not simply use the "compile" scope instead?

The docs don't really help. Any idea?

Maven Solutions


Solution 1 - Maven

runtime is useful for dependencies required for unit tests and at runtime, but not at compile time. This may typically be dynamically loaded code, such as JDBC drivers, which are not directly referenced in the program code.

Setting dependency to runtime ensure that there isn't an accidental dependency on the code, and also keeps the dependency from being transitive. So that, for example, if module A has a runtime dependency on library X, and module B depends on module A, it does not inherit the dependency on library X. Using "provided" or "compile" would cause B to depend on X.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionelectrotypeView Question on Stackoverflow
Solution 1 - MavenJohn StaufferView Answer on Stackoverflow