I'm trying to develop a custom Maven plugin. I'm currently running into this problem when I execute my unit tests: java.lang.NoClassDefFoundError: org.eclipse.aether.RepositorySystemSession
Stack trace is below:
initializationError(com.mycompany.MyPluginTest) Time elapsed: 0 sec (TestSuite.java:132) at org.junit.internal.runners.JUnit38ClassRunner.(JUnit38ClassRunner.java:72) at org.junit.internal.builders.JUnit3Builder.runnerForClass(JUnit3Builder.java:11) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:262) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Caused by: java.lang.ClassNotFoundException: org.eclipse.aether.RepositorySystemSession at java.net.URLClassLoader.findClass(URLClassLoader.java:423) at java.lang.ClassLoader.loadClass(ClassLoader.java:660) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:346) at java.lang.ClassLoader.loadClass(ClassLoader.java:626) at java.lang.J9VMInternals.verifyImpl(Native Method) at java.lang.J9VMInternals.verify(J9VMInternals.java:72) at java.lang.J9VMInternals.verify(J9VMInternals.java:70) at java.lang.J9VMInternals.initialize(J9VMInternals.java:134) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:44) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:516) at junit.framework.TestSuite.createTest(TestSuite.java:63) at junit.framework.TestSuite.addTestMethod(TestSuite.java:310) at junit.framework.TestSuite.addTestsFromTestCase(TestSuite.java:153) at junit.framework.TestSuite.(TestSuite.java:132) at org.junit.internal.runners.JUnit38ClassRunner.(JUnit38ClassRunner.java:72) at org.junit.internal.builders.JUnit3Builder.runnerForClass(JUnit3Builder.java:11) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:262) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
From my research, this can happen when building for Maven 3.1.x because Maven switched from the sonatype aether implementation to the eclipse implementation.
I am trying to build my plugin for Eclipse 3.0.4, since that's what's installed on all our workstations. I'm assuming that I'm seeing this error because one of my dependencies is a Maven 3.1.x dependency, although I'm not sure which one. Does anyone know which dependency I should correct?
Also, does anyone know if it's possible to build a plugin that will work for Maven 3.0.x and 3.1.x? I'd rather not have to go through all this again some day in the future when we move to a newer version of Maven.
The dependencies in my POM look like this:
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.0.4</version>
</dependency>
</dependencies>