title: Optional system dependency causes "invalid, transitive dependencies (if any) will not be available"
body: <p>I have a main project and a commons project which has a dependency that is not in any repository and needs to be included <a href="https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies" rel="nofollow">using <code>&lt;scope&gt;system&lt;/scope&gt;</code></a>.</p>
  
  <p>Because the system dependency is defined using a relative url using a maven property <code>${project.basedir}</code>, I <a href="https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html" rel="nofollow">made it <code>&lt;optional&gt;true&lt;/optional&gt;</code></a> so that it doesn't bother other projects and so depending projects need to redefine this dependency with the correct path.</p>
  
  <p>Commons pom.xml:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;thirdparty-group&lt;/groupId&gt;
      &lt;artifactId&gt;artifact&lt;/artifactId&gt;
      &lt;version&gt;1.4.2&lt;/version&gt;
      &lt;scope&gt;system&lt;/scope&gt;
      &lt;systemPath&gt;${project.basedir}/lib/dependency.jar&lt;/systemPath&gt;
      &lt;optional&gt;true&lt;/optional&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>In main project's pom:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;my-group&lt;/groupId&gt;
      &lt;artifactId&gt;commons&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;thirdparty-group&lt;/groupId&gt;
      &lt;artifactId&gt;artifact&lt;/artifactId&gt;
      &lt;version&gt;1.4.2&lt;/version&gt;
      &lt;scope&gt;system&lt;/scope&gt;
      &lt;systemPath&gt;${project.basedir}/lib/dependency.jar&lt;/systemPath&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Obviously dependency.jar is in both the <em>commons</em> and <em>main</em> project.</p>
  
  <p>The commons jar installs properly without a hitch. But when used in the main project however, the result is:</p>
  
  <blockquote>
    <p>[WARNING] The POM for my-group:commons:jar:1.0-SNAPSHOT is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for my-group:commons:1.0-SNAPSHOT</p>
    
    <p>[ERROR] 'dependencies.dependency.systemPath' for thirdparty-group:artifact:jar must specify an absolute path but is ${project.basedir}/lib/dependency.jar @</p>
  </blockquote>
  
  <p>The build continues, but transitive runtime dependencies are now excluded breaking the application. </p>
  
  <p>Why is maven complaining about a dependency from commons that is not even relevant to the main project (as it is <a href="https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html" rel="nofollow">optional</a>, why is it even included as transitive dependency)?
  How to work around this problem?</p>
  
  <p>Putting the system dependency in the repo is not an option unfortunately. </p>