title: Maven dependency:analyze issues irritating warnings
body: <p>I have a Maven module (part of a multi-module project) with the following dependency declared:</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;commons-logging&lt;/groupId&gt;
    &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
    &lt;version&gt;1.1&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Classes from that package are used in the following way:</p>
  
  <pre><code>private static final Log LOG = LogFactory.getLog(MyClass.class);
  </code></pre>
  
  <p>Everything compiles fine.</p>
  
  <p>When I run <code>mvn dependency:analyze</code> (or <code>analyze-only</code>), the following warning is issued though:</p>
  
  <pre><code>[WARNING] Unused declared dependencies found:
  [WARNING]    commons-logging:commons-logging:jar:1.1:compile
  </code></pre>
  
  <p>This seems to indicated that I could remove the said dependency, in particular because we want to set the <code>failOnWarning</code> option to <code>true</code>, the warning hence results in a build failure. However, the package is clearly required and when I remove it, the module fails to compile:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project mymodule: Compilation failure: Compilation failure:
  [ERROR] MyClass.java:[18,34] package org.apache.commons.logging does not exist
  [ERROR] MyClass.java:[19,34] package org.apache.commons.logging does not exist
  [ERROR] MyClass.java:[44,26] cannot find symbol
  [ERROR] symbol:   class Log
  [ERROR] location: class MyClass
  </code></pre>
  
  <p>There are related questions around: </p>
  
  <p><a href="https://stackoverflow.com/questions/27994153/maven-dependencyanalyze-warnings-for-spring-boot-starter-transitive-dependencie">Why were Spring Boot starter dependencies designed to be used contrary to the stated intent of Maven&#39;s transitive dependency mechanisms?</a>,</p>
  
  <p><a href="https://stackoverflow.com/questions/4919297/how-to-tell-maven-dependency-plugin-that-the-artifact-is-used-in-the-project">How to tell maven-dependency-plugin that the artifact is used in the project?</a>, </p>
  
  <p><a href="http://maven.40175.n5.nabble.com/Why-is-dependency-analyze-lying-to-me-td5784108.html" rel="nofollow noreferrer">Why is dependency:analyze lying to me?</a></p>
  
  <p>but they are either unanswered or the answers relate to problems with scope. In my case, the scope needs to be <code>compile</code> (i.e. no need to declare).</p>