9

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...

Anthony Dahanne
  • 4,823
  • 2
  • 40
  • 39

1 Answers1

2

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.

Robert Scholte
  • 11,889
  • 2
  • 35
  • 44
  • are you saying my plugin should not use aether directly, but rather rely on the Maven dependency tree api ? – Anthony Dahanne Jul 16 '13 at 20:39
  • If that's possible, yes. You haven't explained what your plugin does, but if it's about a (sub)set of dependencies or artifacts, maven-dependency-tree is the answer. Have a look at the sourcecode of the plugins mentioned to see how they resolved it. – Robert Scholte Jul 16 '13 at 21:31
  • @RobertScholte, How can the `maven-dependency-tree` plugin be used? It only exposes a [`DependencyGraphBuilder`](http://maven.apache.org/shared/maven-dependency-tree/apidocs/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.html) ? – Johan Sjöberg Aug 19 '14 at 23:36
  • It's not a plugin, but a `Component`. You can walk through all dependencies (transitive as well), without depending on a specific Maven version. It would help if you explain your usecase. – Robert Scholte Aug 20 '14 at 09:56