title: What are unused/undeclared dependencies in Maven? What to do with them?
body: <p>Maven <code>dependency:analyze</code> complains about the dependencies in my project. How does it determine which are unused and which are undeclared? What should I do about them?</p>
  
  <p>Example:</p>
  
  <pre><code>$ mvn dependency:analyze 
  ...
  [WARNING] Used undeclared dependencies found:
  [WARNING]    org.slf4j:slf4j-api:jar:1.5.0:provided
  [WARNING]    commons-logging:commons-logging:jar:1.1.1:compile
  [WARNING]    commons-dbutils:commons-dbutils:jar:1.1-osgi:provided
  [WARNING]    org.codehaus.jackson:jackson-core-asl:jar:1.6.1:compile
  
  ...
  [WARNING] Unused declared dependencies found:
  [WARNING]    commons-cli:commons-cli:jar:1.0:compile
  [WARNING]    org.mortbay.jetty:servlet-api:jar:2.5-20081211:test
  [WARNING]    org.apache.httpcomponents:httpclient:jar:4.0-alpha4:compile
  [WARNING]    commons-collections:commons-collections:jar:3.2:provided
  [WARNING]    javax.mail:mail:jar:1.4:provided
  </code></pre>
  
  <p>Note:
  A lot of these dependencies are used in my runtime container and I declared them as provided to avoid having the same library on the classpath twice with different versions. </p>