compile
and provided
when artifact is builded as a JAR? If it was WAR, then I understand -
artifact would be attached or not to WEB-INF/lib. But in case of the JAR
it doesn't matter - dependencies aren't attached. They have to be on
classpath when their scope is compile
or provided
. I know that provided
dependencies aren't transitive - but is it only one difference?A:
From the Maven Doc:
Recap:
Source: http://stackoverflow.com/questions/6646959/difference-between-maven-scope-compile-and-provided-for-jar-packaging
This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
- compile
This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
- provided
- dependencies are not transitive (as you mentioned)
- provided scope is only available on the compilation and test classpath, whereas compile scope is available in all classpaths.
- provided dependencies are not packaged
Source: http://stackoverflow.com/questions/6646959/difference-between-maven-scope-compile-and-provided-for-jar-packaging
No comments:
Post a Comment