java - Maven Test Scope -
if have 1 project of mine myproject1 has following depenedencies:
<!-- logging --> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> <version>1.7.6</version> </dependency> <dependency> <groupid>ch.qos.logback</groupid> <artifactid>logback-core</artifactid> <version>1.1.1</version> <scope>test</scope> </dependency> <dependency> <groupid>ch.qos.logback</groupid> <artifactid>logback-classic</artifactid> <version>1.1.1</version> <scope>test</scope> </dependency>
and include myproject1 in myproject2 so:
<dependency> <groupid>com.mydomain</groupid> <artifactid>myproject1</artifactid> <version>1.0</version> </dependency> <!-- android logging--> <dependency> <groupid>com.github.tony19</groupid> <artifactid>logback-android-core</artifactid> <version>1.1.1-2</version> </dependency> <dependency> <groupid>com.github.tony19</groupid> <artifactid>logback-android-classic</artifactid> <version>1.1.1-2</version> </dependency>
i still seeing logback classes being included in myproject2. understanding test scope should prevent jars bleeding parent projects. misunderstanding something? running compilation issues parent project relies on logback-android , have multiple classes same name e.g. ch.qos.logback.classic.asyncappender
.
you can exclude transitive dependencies myproject1
, have 2 options here.
optional dependency. mark logback-core
in myproject1
optional:
<dependency> <groupid>ch.qos.logback</groupid> <artifactid>logback-core</artifactid> <version>1.1.1</version> <scope>test</scope> <optional>true</optional> </dependency>
excluded dependency. exclude logback-core
when including myproject1
:
<dependency> <groupid>com.mydomain</groupid> <artifactid>myproject1</artifactid> <version>1.0</version> <exclusions> <exclusion> <groupid>ch.qos.logback</groupid> <artifactid>logback-core</artifactid> </exclusion> </exclusions> </dependency>
also think if run build tests off (-dmaven.test.skip=true
) logback-core
not included anyway.
run mvn dependency:tree
see origin of dependencies , scope.
Comments
Post a Comment