Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a maven mojo relying on Aether be compatible with Maven 3.0.x and 3.1.x?

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

like image 298
Anthony Dahanne Avatar asked Jul 16 '13 19:07

Anthony Dahanne


People also ask

What is Aether in Maven?

Well, Aether is the answer. It's an easily embeddable Java library to work with artifact repositories, enabling you to fetch artifacts from remote repositories for local consumption and to publish local artifacts to remote repositories for sharing with others.

Which class do all mojos extend from?

Mojo interface, which the Mojo must implement (or else extend its abstract base class counterpart org. apache. maven.

What is Mojo in Maven?

What is a Mojo? A mojo is a Maven plain Old Java Object. Each mojo is an executable goal in Maven, and a plugin is a distribution of one or more related mojos.

How does Maven 3 work?

Maven 3 aims at supporting a stricter separation between the compile/runtime/test dependencies of a project and the plugins used to build the project. For this reason, build extensions, plugins and plugin dependencies are no longer resolved from the <repositories> of a project but only from its <pluginRepositories> .


1 Answers

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.

like image 106
Robert Scholte Avatar answered Oct 18 '22 22:10

Robert Scholte