Why a Maven Plugin - Motivation

Being Apache Maven users to manage projects lyfecycle, and being at the same time MyBatis framework and MyBatis Migration tool to maintain the database structure, in order to have a fully integrated tool we started implementing a solution that mixes the MyBatis Migration tool power into a standard Apache Maven build life cycle.

The MyBatis migrations-maven-plugin aims to perform a complete porting of all MyBatis Migration tool commands to a standard Maven plugin.

A little bit of history

The MyBatis migrations-maven-plugin was born in April 2010 after a Skype conference between Marco Speranza and Simone Tripodi where both were looking for a solution to integrate MyBatis Migration tool into the softrware build life cycle. The project was created and maintained by 99soft.org and posted on Google Code with the name maven-migrate-plugin.

In September 2010 Simone proposed Marco as new MyBatis community member, Clinton Begin and the team accepted letting him bringing the migrations-maven-plugin code base to become an official MyBatis subproject.

By that day, the MyBatis Migration Maven Plugin project is maintained by the MyBatis.org team.

Requirements

Before starting reading the manual, it is very important you're familiar with both MyBatis Migration Tool and Apache Maven and therminology, otherwise it would be very difficult to understand the described context.

Maven 3 and site generation

A significant difference between M2 and M3 is site generation. If you are used to configure the pom reporting section to generate code reports, you should migrate this feature to Maven 3. Indeed, the reporting and reportSets sections have been deprecated (it won't cause an error with Maven 3, they will just be ignored), and have been replaced by the reportPlugins section in the configuration block of the maven-site-plugin itself. A typical Maven 2 pom.xml file looks like this:

<reporting>
  <plugins>
    <plugin>
      <groupId>org.mybatis.maven</groupId>
      <artifactId>migrations-maven-plugin</artifactId>
      <version>1.1.5-SNAPSHOT</version>
      <configuration>
        <repository> [migration repository path] </repository>
      </configuration>
    </plugin>
  </plugins>
</reporting>
If you are using M3 for your project, users have to add the following snippet in order to generate MyBatis Migration Plugin report automatically.
<build>
   <plugins>
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-site-plugin</artifactId>
       <version>3.6</version>
       <configuration>
         <reportPlugins>
           <plugin>
             <groupId>org.mybatis.maven</groupId>
             <artifactId>migrations-maven-plugin</artifactId>
             <version>1.1.5-SNAPSHOT</version>
             <configuration>
               <repository> [migration repository path] </repository>
             </configuration>
           </plugin>
         </reportPlugins>
       </configuration>
     </plugin>
   </plugins>
 </build>

Acknowledgements

A special thanks goes to all the special people who made the Maven Migration Plugin a reality, above all Clinton Begin, who's strongly supporting the subprojects proliferation.