title: Maven plugin AbstractMojoTestCase PlexusContainerException
body: <p>I'm trying to create a maven plugin for the first time.
  everything works till now except for the testing part.
  I want to write some test cases before I start at coding the plugin itself.
  I've had really much trouble till now with being able to simply run a test case that doesn't even do anything itself.</p>
  
  <p>I think I'm missing a dependency or that I'm using compatible versions. I've messed much with the versions and the exceptions have changed a lot. But this one keeps coming back.</p>
  
  <p>So when I run <code>mvn test</code> I get the following response from the console:</p>
  
  <pre><code>λ mvn test
  [INFO] Scanning for projects...
  [INFO]
  [INFO] ------------------------------------------------------------------------
  [INFO] Building Simple Web Share Plugin 1.2.9-SNAPSHOT
  [INFO] ------------------------------------------------------------------------
  [INFO]
  [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sws-maven-plugin ---
  [INFO] Using '' encoding to copy filtered resources.
  [INFO] skip non existing resourceDirectory maven-sws-plugin\src\main\resources
  [INFO]
  [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ sws-maven-plugin ---
  [INFO] Changes detected - recompiling the module!
  [INFO] Compiling 4 source files to maven-sws-plugin\target\classes
  [INFO]
  [INFO] --- maven-plugin-plugin:3.2:descriptor (default-descriptor) @ sws-maven-plugin ---
  [INFO] Using '' encoding to read mojo metadata.
  [INFO] Applying mojo extractor for language: java
  [INFO] Mojo extractor for language: java found 0 mojo descriptors.
  [INFO] Applying mojo extractor for language: bsh
  [INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
  [INFO] Applying mojo extractor for language: java-annotations
  [INFO] Mojo extractor for language: java-annotations found 1 mojo descriptors.
  [INFO]
  [INFO] --- maven-plugin-plugin:3.2:descriptor (mojo-descriptor) @ sws-maven-plugin ---
  [INFO] Using '' encoding to read mojo metadata.
  [INFO] Applying mojo extractor for language: java
  [INFO] Mojo extractor for language: java found 0 mojo descriptors.
  [INFO] Applying mojo extractor for language: bsh
  [INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
  [INFO] Applying mojo extractor for language: java-annotations
  [INFO] Mojo extractor for language: java-annotations found 1 mojo descriptors.
  [INFO]
  [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ sws-maven-plugin ---
  [INFO] Using '' encoding to copy filtered resources.
  [INFO] Copying 1 resource
  [INFO]
  [INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ sws-maven-plugin ---
  [INFO] Nothing to compile - all classes are up to date
  [INFO]
  [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ sws-maven-plugin ---
  [INFO] Surefire report directory: maven-sws-plugin\target\surefire-reports
  
  -------------------------------------------------------
   T E S T S
  -------------------------------------------------------
  Running plugins.MojoTest
  org.codehaus.plexus.PlexusContainerException: Cycle detected in component graph in the system:
          at org.codehaus.plexus.DefaultPlexusContainer.initialize(DefaultPlexusContainer.java:624)
          at org.codehaus.plexus.DefaultPlexusContainer.construct(DefaultPlexusContainer.java:281)
          at org.codehaus.plexus.DefaultPlexusContainer.&lt;init&gt;(DefaultPlexusContainer.java:172)
          at org.apache.maven.plugin.testing.AbstractMojoTestCase.setupContainer(AbstractMojoTestCase.java:159)
          at org.apache.maven.plugin.testing.AbstractMojoTestCase.getContainer(AbstractMojoTestCase.java:179)
          at org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp(AbstractMojoTestCase.java:107)
          at nl.ciber.maven.plugins.MojoTest.setUp(MojoTest.java:11)
          at junit.framework.TestCase.runBare(TestCase.java:125)
          at junit.framework.TestResult$1.protect(TestResult.java:106)
          at junit.framework.TestResult.runProtected(TestResult.java:124)
          at junit.framework.TestResult.run(TestResult.java:109)
          at junit.framework.TestCase.run(TestCase.java:118)
          at junit.framework.TestSuite.runTest(TestSuite.java:208)
          at junit.framework.TestSuite.run(TestSuite.java:203)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:95)
          at org.apache.maven.surefire.junit.JUnit3Provider.executeTestSet(JUnit3Provider.java:121)
          at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:98)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
          at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
          at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
          at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
          at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
  Caused by: org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException: Cyclic requirement detected
          at org.codehaus.plexus.component.composition.DefaultCompositionResolver.addComponentDescriptor(DefaultCompositionResolver.java:65)
          at org.codehaus.plexus.component.repository.DefaultComponentRepository.addComponentDescriptor(DefaultComponentRepository.java:229)
          at org.codehaus.plexus.DefaultComponentRegistry.addComponentDescriptor(DefaultComponentRegistry.java:126)
          at org.codehaus.plexus.DefaultPlexusContainer.addComponentDescriptor(DefaultPlexusContainer.java:514)
          at org.codehaus.plexus.DefaultPlexusContainer.discoverComponents(DefaultPlexusContainer.java:969)
          at org.codehaus.plexus.DefaultPlexusContainer.discoverComponents(DefaultPlexusContainer.java:941)
          at org.codehaus.plexus.DefaultPlexusContainer.initialize(DefaultPlexusContainer.java:560)
          ... 29 more
  Caused by: org.codehaus.plexus.util.dag.CycleDetectedException: Edge between 'Vertex{label='org.apache.maven.plugin.version.PluginVersionResolver:default'}' and 'Vertex{label='org.apache.maven.plugin.MavenPluginManager:default'}' introduces to cycle in the graph org.apache.maven.plugin.MavenPluginManager:default --&gt; org.apache.maven.plugin.version.PluginVersionResolver:default --&gt; org.apache.maven.plugin.MavenPluginManager:default
          at org.codehaus.plexus.util.dag.DAG.addEdge(DAG.java:143)
          at org.codehaus.plexus.util.dag.DAG.addEdge(DAG.java:123)
          at org.codehaus.plexus.component.composition.DefaultCompositionResolver.addComponentDescriptor(DefaultCompositionResolver.java:60)
          ... 35 more
  Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.726 sec &lt;&lt;&lt; FAILURE!
  testFilePath(***.maven.plugins.MojoTest)  Time elapsed: 0.686 sec  &lt;&lt;&lt; FAILURE!
  junit.framework.AssertionFailedError: Failed to create plexus container.
          at junit.framework.Assert.fail(Assert.java:47)
          at org.apache.maven.plugin.testing.AbstractMojoTestCase.setupContainer(AbstractMojoTestCase.java:164)
          at org.apache.maven.plugin.testing.AbstractMojoTestCase.getContainer(AbstractMojoTestCase.java:179)
          at org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp(AbstractMojoTestCase.java:107)
          at ***.maven.plugins.MojoTest.setUp(MojoTest.java:11)
          at junit.framework.TestCase.runBare(TestCase.java:125)
          at junit.framework.TestResult$1.protect(TestResult.java:106)
          at junit.framework.TestResult.runProtected(TestResult.java:124)
          at junit.framework.TestResult.run(TestResult.java:109)
          at junit.framework.TestCase.run(TestCase.java:118)
          at junit.framework.TestSuite.runTest(TestSuite.java:208)
          at junit.framework.TestSuite.run(TestSuite.java:203)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:95)
          at org.apache.maven.surefire.junit.JUnit3Provider.executeTestSet(JUnit3Provider.java:121)
          at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:98)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
          at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
          at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
          at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
          at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
  
  
  Results :
  
  Failed tests:   testFilePath(***.maven.plugins.MojoTest): Failed to create plexus container.
  
  Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
  
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 13.595 s
  [INFO] Finished at: 2017-03-24T10:35:35+01:00
  [INFO] Final Memory: 32M/497M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project sws-maven-plugin: There are test failures.
  [ERROR]
  [ERROR] Please refer to maven-sws-plugin\target\surefire-reports for the individual test results.
  [ERROR] -&gt; [Help 1]
  [ERROR]
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR]
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
  </code></pre>
  
  <p>My POM.xml (I've added a few things what are proberally not needed, I've googled a lot and nothing worked till now):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;***.maven.plugin.sws&lt;/groupId&gt;
      &lt;artifactId&gt;sws-maven-plugin&lt;/artifactId&gt;
      &lt;packaging&gt;maven-plugin&lt;/packaging&gt;
      &lt;version&gt;1.2.9-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;Simple Web Share Plugin&lt;/name&gt;
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;Cp1252&lt;/project.build.sourceEncoding&gt;
          &lt;maven.version&gt;3.5.0-alpha-1&lt;/maven.version&gt;
      &lt;/properties&gt;
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;mavencentral&lt;/id&gt;
              &lt;name&gt;Maven Central&lt;/name&gt;
              &lt;url&gt;https://repo1.maven.org/maven2/&lt;/url&gt;
              &lt;layout&gt;default&lt;/layout&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;reporting&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-plugin-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.4&lt;/version&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/reporting&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.8&lt;/source&gt;
                      &lt;target&gt;1.8&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-plugin-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.2&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;mojo-descriptor&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;descriptor&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;configuration&gt;
                      &lt;skipErrorNoDescriptorsFound&gt;true&lt;/skipErrorNoDescriptorsFound&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
  
          &lt;directory&gt;${project.basedir}/target&lt;/directory&gt;
          &lt;outputDirectory&gt;${project.build.directory}/classes&lt;/outputDirectory&gt;
          &lt;finalName&gt;${project.artifactId}-${project.version}&lt;/finalName&gt;
          &lt;testOutputDirectory&gt;${project.build.directory}/test-classes&lt;/testOutputDirectory&gt;
          &lt;sourceDirectory&gt;${project.basedir}/src/main/java&lt;/sourceDirectory&gt;
          &lt;testSourceDirectory&gt;${project.basedir}/src/test/java&lt;/testSourceDirectory&gt;
          &lt;resources&gt;
              &lt;resource&gt;
                  &lt;directory&gt;${project.basedir}/src/main/resources&lt;/directory&gt;
              &lt;/resource&gt;
          &lt;/resources&gt;
          &lt;testResources&gt;
              &lt;testResource&gt;
                  &lt;directory&gt;${project.basedir}/src/test/resources&lt;/directory&gt;
              &lt;/testResource&gt;
          &lt;/testResources&gt;
  
      &lt;/build&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.fusesource.fabric&lt;/groupId&gt;
              &lt;artifactId&gt;fabric-maven-proxy&lt;/artifactId&gt;
              &lt;version&gt;7.0.1.fuse-084&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;***.webshare&lt;/groupId&gt;
              &lt;artifactId&gt;simple-web-share-api&lt;/artifactId&gt;
              &lt;version&gt;0.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.eclipse.aether&lt;/groupId&gt;
              &lt;artifactId&gt;aether-api&lt;/artifactId&gt;
              &lt;version&gt;1.1.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.maven&lt;/groupId&gt;
              &lt;artifactId&gt;maven-plugin-api&lt;/artifactId&gt;
              &lt;version&gt;${maven.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.maven&lt;/groupId&gt;
              &lt;artifactId&gt;maven-settings&lt;/artifactId&gt;
              &lt;version&gt;${maven.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;jdom&lt;/groupId&gt;
              &lt;artifactId&gt;jdom&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.0.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
              &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.plexus&lt;/groupId&gt;
              &lt;artifactId&gt;plexus-utils&lt;/artifactId&gt;
              &lt;version&gt;3.0.8&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.plexus&lt;/groupId&gt;
              &lt;artifactId&gt;plexus-container-default&lt;/artifactId&gt;
              &lt;!--&lt;version&gt;1.5.5&lt;/version&gt;--&gt;
              &lt;version&gt;1.7.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.maven&lt;/groupId&gt;
              &lt;artifactId&gt;maven-artifact&lt;/artifactId&gt;
              &lt;version&gt;${maven.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.maven&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compat&lt;/artifactId&gt;
              &lt;version&gt;3.3.9&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-io&lt;/groupId&gt;
              &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
              &lt;version&gt;2.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.maven.plugin-testing&lt;/groupId&gt;
              &lt;artifactId&gt;maven-plugin-testing-harness&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.maven&lt;/groupId&gt;
              &lt;artifactId&gt;maven-core&lt;/artifactId&gt;
              &lt;version&gt;3.5.0-alpha-1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;3.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.maven.plugin-tools&lt;/groupId&gt;
              &lt;artifactId&gt;maven-plugin-annotations&lt;/artifactId&gt;
              &lt;version&gt;3.2&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>My POM for testing:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;***.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;sws-maven-plugin&lt;/artifactId&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
      &lt;version&gt;1.9.2-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;reminder-maven-plugin Maven Mojo&lt;/name&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;3.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;***.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;sws-maven-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;test&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>TestCase:</p>
  
  <pre><code>package ***.maven.plugins;
  
  import org.apache.maven.plugin.testing.AbstractMojoTestCase;
  
  /**
   * Created by casper.hollemans on 20-3-2017.
   */
  public class MojoTest extends AbstractMojoTestCase {
  
      public void setUp() throws Exception {
          super.setUp();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
      }
  
      public void testFilePath() throws Exception {
  
  
  
      }
  
  }
  </code></pre>