1

I have a war file that gets a slf4j-jdk14 dependency in WEB-INF/lib when I run mvn package and I can't figure out how it's getting in there. CD'd into the director of the war and ran mvn dependency:tree -Dverbose. The only line that mentions slf4j-jdk14 is this:

[INFO]    +- org.slf4j:slf4j-jdk14:jar:1.6.1:provided

You can see the full output here: https://gist.github.com/dankmirth/691b020f4f908f92015f

I can comment out this dependency in the pom. When I do that, mvn dependency:tree -Dverbose doesn't mention slf4j-jdk14 at all. But, if I then run mvn clean package the war still has this jar in it.

How is this possible? Does dependency:tree only show part of the picture? Is this a maven bug?

$ mvn -version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 08:22:22-0700)

If I run help:effective-pom only had a reference to slf4j-jdk14 is in a line that's excluding it. The war plugin looks standard to me here's the output:

  <plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1.1</version>
    <executions>
      <execution>
        <id>default-war</id>
        <phase>package</phase>
        <goals>
          <goal>war</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

Although I'd love to provide a pom for this, I can't because my company wouldn't allow it. I've tried to reproduce this in a sample project and have been unable to. I'm hoping some expert out there can point me down a path to debug where this jar is coming from because in my understanding of maven, this shouldn't be possible.

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356

1 Answers1

0

This answer to a previous question says that the war plugin does not seem to exclude the jar when copying dependencies even when the transitive dependency is excluded. So you can try to exclude some other transitive dependency in your pom and check if it does not get copied. If it still gets copied, it means that your slf4j-jdk14 gets copied the same way.

If that is the case, you can try to exclude it using the war plugin configuration.

Community
  • 1
  • 1
Can't Tell
  • 12,714
  • 9
  • 63
  • 91
  • OK, but what about where I said, "I can comment out this dependency in the pom. When I do that, `mvn dependency:tree -Dverbose` doesn't mention slf4j-jdk14 at all." Doesn't that mean the war plugin can't even see slf4j-jdk14, transitive or not? – Daniel Kaplan Jan 25 '14 at 07:59
  • BTW, I think that the war plugin configuration will probably fix my issue (I'll try it and let you know), but I'd like to *confidently understand* why this is happening before I mark this as the answer. – Daniel Kaplan Jan 25 '14 at 08:00
  • @tieTYT from what I understood from the link, the war plugin doesn't seem to work with the dependency tree. Maybe it has its own logic of figuring out which jars should get copied and that logic (maybe by mistke?) doesn't exclude the artifacts excluded using the exclude tag. – Can't Tell Jan 25 '14 at 09:36