1

This is how my application POM looks and it uses a custom framework built on top of spring called myframework. Since it runs on websphere, and the core libraries are available as shared library in run time, I want to only package web library into my WAR. Though I have my shared library dependency defined with provided scope, and added the shared library BOM containing all the core libraries defined in provided scope. One of the transitive dependency which is part of core library slf4j is coming in compile scope, and it gets packaged inside the war, which I don't expect to happen. There are many core dependency like this which are getting into compile scope. Why is this happening?

Based on this post Maven transitive dependency has scope compile while when dependency has provided scope My core library should be in provided scope, as I have imported a BOM which has all this core library defined in provided scope but that is not happening. I have also provided the maven dependency tree below. Please advice.

Note: I am involved in the development of the framework and I don't want to directly include all of the core jar in dependencymanagement section in provided scope in the application, as there are lot of libraries and I don't want each developers using this framework to be aware of all the core jars, and include them in dependencymanagement section instead want them to use a BOM/POM.

    <dependencyManagement>
       <dependencies>
        <dependency>
            <groupId>com.myframework</groupId>
            <artifactId>myframework-shared-libs-bom</artifactId>
            <version>${library.version}</version>
            <scope>import</scope>
        </dependency>
      </dependencies>
    </dependencyManagement>

  <dependencies>
    <dependency>
          <groupId>com.myframework</groupId>
          <artifactId>myframework-shared-libs</artifactId>
          <version>${library.version}</version>
          <type>pom</type>
          <scope>provided</scope>
        </dependency>

        <dependency>
          <groupId>com.myframework</groupId>
          <artifactId>myframework-web-libs</artifactId>
          <version>${library.version}</version>
          <type>pom</type>
        </dependency>
  </dependencies>

Maven Dependency tree

+- com.myframework:myframework-shared-libs:pom:4.0.0-SNAPSHOT:provided
|  \- org.slf4j:jcl-over-slf4j:jar:1.7.6:provided
\- com.myframework:myframework-web-libs:pom:4.0.0-SNAPSHOT:compile
   \- com.myframework:myframework-web:jar:4.0.0-SNAPSHOT:compile
      \- com.myframework:myframework-core:jar:4.0.0-SNAPSHOT:compile
         \- org.slf4j:slf4j-api:jar:1.7.21:compile
Community
  • 1
  • 1

0 Answers0