title: Maven says I have a cyclic reference in multi-module project but can't figure out why
body: <p>I have a multi-module project that looks like this:</p>
  
  <ul>
  <li>module1
  <ul>
  <li>pom.xml</li>
  </ul></li>
  <li>module2
  <ul>
  <li>pom.xml</li>
  </ul></li>
  <li>pom.xml</li>
  </ul>
  
  <p>The pom.xml in module2 has a dependency on module1.</p>
  
  <p>When I run mvn clean compile I get the following error:</p>
  
  <blockquote>
    <p>The projects in the reactor contain a cyclic reference.</p>
  </blockquote>
  
  <p>Here are my dependencies in module1:</p>
  
  <pre><code>&lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j&lt;/artifactId&gt;
          &lt;version&gt;1.2.14&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
          &lt;version&gt;1.6.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.jcraft&lt;/groupId&gt;
          &lt;artifactId&gt;jsch&lt;/artifactId&gt;
          &lt;version&gt;0.1.48&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>I can't figure out why it says there is a cyclic reference.  Even when I do mvn dependency:tree on module1 I get the following:</p>
  
  <pre><code>[INFO] +- log4j:log4j:jar:1.2.14:compile
  [INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
  [INFO] |  \- org.slf4j:slf4j-api:jar:1.6.1:compile
  [INFO] +- com.jcraft:jsch:jar:0.1.48:compile
  [INFO] \- junit:junit:jar:4.8.2:test
  </code></pre>
  
  <p>It looks to me like there aren't any references to module2 in module1. So where is the cyclic reference coming from?</p>
  
  <p>Edit: Here is the log with debug on:</p>
  
  <pre><code>+ Error stacktraces are turned on.
  Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
  Java version: 1.6.0_31
  Default locale: en_US, platform encoding: Cp1252
  OS name: "windows 7" version: "6.1" arch: "amd64" Family: "windows"
  [INFO] Scanning for projects...
  [INFO] ------------------------------------------------------------------------
  [ERROR] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='com.myorg:module2'}' and 'Vertex{label='com.myorg:module1'}' introduces to cycle in the graph com.myorg:module1 --&gt; com.myorg:module2 --&gt; com.myorg:module1
  [INFO] ------------------------------------------------------------------------
  [DEBUG] Trace
  org.apache.maven.BuildFailureException: The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='com.myorg:module2'}' and 'Vertex{label='com.myorg:module1'}' introduces to cycle in the graph com.myorg:module1 --&gt; com.myorg:module2 --&gt; com.myorg:module1
  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:295)
  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
  at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
  at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
  at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
  at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
  at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
  Caused by: hidden.org.codehaus.plexus.util.dag.CycleDetectedException: Edge between 'Vertex{label='com.myorg:module2'}' and 'Vertex{label='com.myorg:module1'}' introduces to cycle in the graph com.myorg:module1 --&gt; com.myorg:module2 --&gt; com.myorg:module1
  at hidden.org.codehaus.plexus.util.dag.DAG.addEdge(DAG.java:143)
  at hidden.org.codehaus.plexus.util.dag.DAG.addEdge(DAG.java:123)
  at org.apache.maven.project.ProjectSorter.&lt;init&gt;(ProjectSorter.java:118)
  at org.apache.maven.execution.ReactorManager.&lt;init&gt;(ReactorManager.java:99)
  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:288)
  ... 11 more
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: &lt; 1 second
  [INFO] Finished at: Thu Jul 05 17:21:21 EDT 2012    
  [INFO] Final Memory: 3M/244M
  [INFO] ------------------------------------------------------------------------
  </code></pre>