New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provided dependency that is also a transitive dependency should be considered provided #4632
Comments
@fxbonnet Thanks for the report. This does not match my expectation.
If you extend your logic, a direct dependency in |
@eed3si9n thanks for your answer. But you are perfectly right, if I have a My example works as I expect with maven If you want to reproduce: pom.xml <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>testProvidedDeps</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>project1</module>
<module>project2</module>
</modules>
</project> project1/pom.xml <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>testProvidedDeps</artifactId>
<groupId>test</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>project1</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
</project> project2/pom.xml <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>testProvidedDeps</artifactId>
<groupId>test</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>project2</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>project1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project> |
I think you'd need to mess with sbt-assembly settings to exclude it manually. |
I agree with @fxbonnet that I don't think the current behavior is the desired one or least some way of achive the other behavior is desired. Am I missing some easy way that currently achieves the same thing? If not I would be willing to help implement such a feature. My use case is that we currently build a fat jar using sbt-assembly for running against a a provided spark runtime. So it would be desired that the fat jar does not contain spark or any of sparks transitive dependencies (if it does it easy to end up with multiple versions of libraries). From what I can tell sbt-assembly does not provide some easy way to exclude all the transitive dependencies and you end up needing to exclude all (or at least all that you have overlap with) of them manually. |
To some extent this is more of a design problem at the layer of dependency management engine. Could either of you open an issue on coursier/coursier? My guess is that any implementation effort would need to happen there. |
steps
If I have a project
project1
that has a dependency (compile) to a libraryAnd a project
project2
that has a dependency (compile) toproject1
but inproject2
the same library is providedproblem
In
project2
the library is resolved as a compile dependency. As a result if I generate a fat jar, it is included in the jar while it is not needed.expectation
As the library is provided in
project2
it should be resolved as provided and not included when doing an assemblynotes
Sample project to reproduce the issue:
build.sbt
plugins.sbt
sbt version: 1.2.8
The text was updated successfully, but these errors were encountered: