问题
The 3.1.0 release of Maven relies on Eclipse Aether (org.eclipse.aether) instead of Sonatype Aether (org.sonatype.aether). This seems to break compatibility for plugins relying on Sonatype aether : try running such plugins and you'll run into :
java.lang.NoClassDefFoundError: org/sonatype/aether/*
Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.*
As documented in https://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound
Now, is it possible to make a mojo relying on aether classes (such as org.sonatype.aether.RepositorySystemSession) run both with Maven 3.0.x and Maven 3.1.x ?
Or do I have to release two versions of the same plugin, one for 3.0.x and one for 3.1.x ? Putting enforcer rules like this :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[3.0,3.1)</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
I already posted the question on Maven developers mailing list, but no answer so far...
回答1:
Most of these plugins depend on the Maven Dependency Tree, which is capable to collect the right set of dependencies no matter the Maven Version. Version 2.1 was released to support Eclipse Aether next to Sonatype Aether If your plugin can use this component, you should be save.
来源:https://stackoverflow.com/questions/17685441/can-a-maven-mojo-relying-on-aether-be-compatible-with-maven-3-0-x-and-3-1-x