In this article we will walk through a sample migration of a Spring Boot REST Application to Quarkus using Red Hat Migration Toolkit for Applications (MTA).
Overview of Red Hat Migration Toolkit
The Migration Toolkit for Applications (MTA) is an extensible tool which you can use to simplify the migration of several Java applications. This tool is available in several formats. The most common ones are:
- The Web application Toolkit: which you can deploy on the top of a Container and use its UI to complete the migration
- The Command Line Interface: which you can use to perform the migrations from the OS Shell
When you start the MTA tool, it will go through the application artifacts and archives producing as result an HTML report which highlights all the needing changes.
The most common migration patterns are:
- Oracle Weblogic / IBM WebSphere to JBoss Enterprise Application server
- JBoss EAP upgrade to the latest release
- Making your application container-ready
- Oracle JDK to OpenJDK
- Spring Boot to Quarkus
We will show as an example how to prepare a Spring Boot REST/JPA application to Quarkus using the MTA Command Line Interface. You can perform the same steps with another flavor of MTA.
First things first. Head to the Download page and choose which type of toolkit you want to download. In our case, we will go for the CLI. Next, unzip the Toolkit in a folder of your likes:
$ unzip migrationtoolkit-mta-cli-5.2.1-offline.zip -d /path
Then, move to the bin folder where the MTA is available:
A typical MTA execution includes the following arguments:
$ ./mta-cli --input /path/to/jee-example-app-1.0.0.ear \ --output /path/to/output --source weblogic --target eap:7 \ --packages com.acme org.apache
Here is a short description of the arguments:
- input is the application that you want to migrate.
- output is the folder where MTA will create its reports
- source is the product/framework that you are migrating from
- target is the destination which you want to migrate to
- packages you can optionally use it to indicate which packages will be checked. Highly recommended to improve performance.
The MTA has an –help command to print the list of available commands. Besides that, you can enable bash auto-completion by running the mta-cli script available in the bash-completion folder:
$ source <MTA_HOME>/bash-completion/mta-cli
In order to migrate our Spring Boot application, we will check the list of source technologies available by running the CLI with the –listSourcetecnologies:
./mta-cli --listSourceTechnologies agroal amazon apicurio artemis avro . . . . springboot thorntail weblogic websphere
Therefore, the correct source technology for a SpringBoot application is “springboot“.
Here is the command to migrate the Spring Boot application “cruddemo-0.0.1-SNAPSHOT.jar”:
./mta-cli --input cruddemo-0.0.1-SNAPSHOT.jar --output ./output --source springboot --target quarkus
The execution will take a while, depending on how many classes and jar files are in your application. At the end of it, you will have in the output folder an index.html page with a set of sub folders:
$ ls index.html reports stats
Checking the Migration Report
By opening the index.html page you will see the list of applications which MTA has inspected:
Click on the application link (cruddemo-0.0.1-SNAPSHOT.jar) to access the MTA DashBoard:
There you can see a recap of all Incidents grouped by Category, Type and the migration complexity. Here is, for example, the list of Mandatory changes for our application:
|Replace Spring datasource property key/value pairs with Quarkus properties||3||1||Trivial change or 1-1 library swap||3|
|Replace the Spring Web artifact with Quarkus ‘spring-web’ extension||2||1||Trivial change or 1-1 library swap||2|
|Replace the SpringBoot Data JPA artifact with Quarkus ‘spring-data-jpa’ extension||2||1||Trivial change or 1-1 library swap||2|
|Replace the Spring Parent POM with Quarkus BOM||1||1||Trivial change or 1-1 library swap||1|
|Replace the SpringBoot artifact with Quarkus ‘spring-boot-properties’ extension||1||1||Trivial change or 1-1 library swap|
If you want to have a project-wise view of the migration steps, check the Application Details Menu:
The level of effort is represented in MTA reports as Story Points. Actual estimates will be based on the skills and amount of changes you will need to apply to complete the migration.
Finally, several other options are available in the report depending on the content of your application. For example:
- Unparsable: Shows all files that MTA could not parse in the expected format.
- JPA: Contains details on all JPA resources that are in your application
- Spring Beans: Contains a list of Spring beans which MTA has detected.
- Ignored Files: Lists the files found in the application that, based on certain rules and configuration, were not processed.
Creating Maven projects from a source artifact
MTA is not just about migration but it includes many other hacks. For example, you can create a full Maven project from a compiled project. This is a great option if you need a project starting point with all the necessary dependencies and APIs for your application. In order to do that, simply add the –mavenize flag to the CLI, as in the following example:
./mta-cli --input cruddemo-0.0.1-SNAPSHOT.jar --output .output --source springboot --target quarkus --mavenize
Within the mavenize folder, you will find a Maven project with the following content:
$ tree mavenized/ mavenized/ └── demo ├── demo │ └── pom.xml ├── demo-bom │ └── pom.xml ├── jackson-annotations │ └── pom.xml ├── jackson-core │ └── pom.xml ├── jackson-databind │ └── pom.xml ├── jackson-datatype-jdk8-jar │ └── pom.xml ├── jackson-datatype-jsr310-jar │ └── pom.xml ├── jackson-module-parameter-names │ └── pom.xml └── pom.xml
As you can see, there are several resources in the target folder:
- A root POM file. This is the pom.xml file at the top-level directory.
- A Bill of Materials (BOM) file. The purpose of this BOM is to have the versions of third-party dependencies used by the project defined in one place.
- One or more application POM files. Each module has its POM file in a directory named after the archive.
In this article we walked through an example of a Spring Boot to Quarkus migration using Red Hat Migration Toolkit. Several other resources are available on the Official Page of the MTA.