java - Transitive dependencies coming from provided scope dependency -
i have added vaadin-client-compiler
dependency provided
scope dependency in vaadin application pom.
as have read, provided
dependency not transitive, dependencies of vaadin-client-compiler
should become dependencies of webapp.
but, found dependencies of vaadin-client-compiler
(commons-lang3-3.1.jar) inside web-inf/lib directory.
also, these dependencies shown in mvn dependency:tree
output well.
[info] | +- javax.validation:validation-api:jar:1.0.0.ga:compile [info] | \- javax.validation:validation-api:jar:sources:1.0.0.ga:compile [info] +- com.vaadin:vaadin-client-compiler:jar:7.6.4:provided [info] | +- com.vaadin:vaadin-sass-compiler:jar:0.9.13:compile [info] | | \- com.yahoo.platform.yui:yuicompressor:jar:2.4.8:compile [info] | | \- rhino:js:jar:1.7r2:compile [info] | +- commons-collections:commons-collections:jar:3.2.2:compile ................................................ ................................................. [info] | +- commons-codec:commons-codec:jar:1.8:compile [info] | +- commons-io:commons-io:jar:2.4:compile [info] | +- org.apache.commons:commons-lang3:jar:3.1:compile
question: why did dependencies of provided
scope dependency became dependencies of webapp?
indeed, according official maven dependency mediation, provided
scope bring in transitive dependencies following:
- transitive dependencies in
compile
scope > fetchedprovided
scope - transitive dependencies in
provided
scope > ignored - transitive dependencies in
runtime
scope > fetchedprovided
scope - transitive dependencies in
test
scope > ignored
hence, transitive dependencies of provided
dependency either ignored or imported provided
, such no part of final packaged war
.
adding following dependency sample project:
<dependencies> <dependency> <groupid>com.vaadin</groupid> <artifactid>vaadin-client-compiler</artifactid> <version>7.6.4</version> <scope>provided</scope> </dependency> </dependencies>
would lead following, executing:
mvn dependency:tree -dincludes=com.vaadin
we have part of output:
[info] \- com.vaadin:vaadin-client-compiler:jar:7.6.4:provided [info] +- com.vaadin:vaadin-shared:jar:7.6.4:provided [info] +- com.vaadin:vaadin-server:jar:7.6.4:provided [info] +- com.vaadin:vaadin-client:jar:7.6.4:provided [info] +- com.vaadin:vaadin-sass-compiler:jar:0.9.13:provided [info] \- com.vaadin:vaadin-client-compiler-deps:jar:1.2.0:provided
perfectly consistent documentation.
however, if add pom.xml
file following:
<dependencymanagement> <dependencies> <dependency> <groupid>com.vaadin</groupid> <artifactid>vaadin-server</artifactid> <version>7.6.4</version> <scope>compile</scope> </dependency> </dependencies> </dependencymanagement>
note: overriding scope of 1 of transitive dependencies compile
.
re-executing previous command have:
[info] \- com.vaadin:vaadin-client-compiler:jar:7.6.4:provided [info] +- com.vaadin:vaadin-shared:jar:7.6.4:compile [info] +- com.vaadin:vaadin-server:jar:7.6.4:compile [info] +- com.vaadin:vaadin-client:jar:7.6.4:provided [info] +- com.vaadin:vaadin-sass-compiler:jar:0.9.13:compile [info] \- com.vaadin:vaadin-client-compiler-deps:jar:1.2.0:provided
which means: transitive dependency vaadin-server
still brought in vaadin-client-compiler
, scope @ compile
per dependency management.
hence, should:
- check whether
pom.xml
definesdependencymanagement
section - check whether parent pom or pom in hierarchy so, executing
mvn help:effective-pom -doutput=full-pom.xml
help - check whether active profile influence build, executing
mvn help:active-profiles
help
Comments
Post a Comment