0

This question is very similar to question Maven Include Dependency in Shaded Jar Only.

My problem was that I wanted to have slf4j-simple included in shaded jar as it is meant for standalone execution and needed proper logging.

<dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.21</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.21</version>
    </dependency>

</dependencies>

I tried using <scope>provided</scope> but then failed to make maven-shade-plugin to include it.

Community
  • 1
  • 1
Davor Hrg
  • 187
  • 1
  • 11

1 Answers1

1

The solution I found was using <optional>true</optional> in the dependency declaration. Since scope was enough for me previously, I was unaware of this option.

<dependencies>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.21</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.21</version>
        <optional>true</optional>
    </dependency>

</dependencies>
Davor Hrg
  • 187
  • 1
  • 11